SG Optimizer - Version 7.2.1

Version Description

Download this release

Release Info

Developer ignatggeorgiev
Plugin Icon 128x128 SG Optimizer
Version 7.2.1
Comparing to
See all releases

Code changes from version 7.2.0 to 7.2.1

core/DNS/Cloudflare.php CHANGED
@@ -413,6 +413,11 @@ class Cloudflare {
413
  return false;
414
  }
415
 
 
 
 
 
 
416
  // Check for all domain entries on the SiteGround App, listing cf_enable variable and the name of the app.
417
  $result = exec( 'site-tools-client domain-all list -f cf_enabled,name', $stc_output );
418
 
@@ -462,4 +467,60 @@ class Cloudflare {
462
 
463
  return false;
464
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  }
413
  return false;
414
  }
415
 
416
+ // Check if domain entries have SG cdn enabled.
417
+ if ( self::is_siteground_cdn() ) {
418
+ return false;
419
+ }
420
+
421
  // Check for all domain entries on the SiteGround App, listing cf_enable variable and the name of the app.
422
  $result = exec( 'site-tools-client domain-all list -f cf_enabled,name', $stc_output );
423
 
467
 
468
  return false;
469
  }
470
+
471
+ /**
472
+ * Check if SiteGround CDN is active.
473
+ *
474
+ * @since 7.2.1
475
+ *
476
+ * @return boolean True if enabled, false otherwise.
477
+ */
478
+ public static function is_siteground_cdn() {
479
+ $sg_cdn_check = exec( 'site-tools-client domain-all list -f settings.cdn_enabled,name', $stc_cdn_output );
480
+
481
+ // Check if shell is empty.
482
+ if ( empty( $sg_cdn_check ) ) {
483
+ return false;
484
+ }
485
+
486
+ // Bail if the output is empty.
487
+ if ( empty( $stc_cdn_output ) ) {
488
+ return false;
489
+ }
490
+
491
+ // Iterate each line of the output.
492
+ foreach ( $stc_cdn_output as $line ) {
493
+ // Break each line into chunks, one with the domain and one with the cf_enabled status.
494
+ $str_arr = explode( ' ', $line );
495
+
496
+ // Bail if one of the variables is empty.
497
+ if (
498
+ empty( $str_arr[0] ) ||
499
+ empty( $str_arr[1] )
500
+ ) {
501
+ continue;
502
+ }
503
+
504
+ // Parse output into php variables.
505
+ parse_str( $str_arr[1], $domain );
506
+ parse_str( $str_arr[0], $cf_enabled );
507
+
508
+ // Bail if SG CDN flag is missing or equal to 0.
509
+ if (
510
+ empty( $cf_enabled['settings_cdn_enabled'] ) ||
511
+ '0' === $cf_enabled
512
+ ) {
513
+ continue;
514
+ }
515
+
516
+ // Remove all subdomains from the url, except www.
517
+ preg_match( "/^(?:https?:\/\/)?(?:www\.)?([^\/]+)/im", get_home_url(), $matches );
518
+
519
+ // Return true if the domain is the same as the one of the current website.
520
+ if ( $matches[1] === $domain['name'] ) {
521
+ return true;
522
+ }
523
+ }
524
+ return false;
525
+ }
526
  }
readme.txt CHANGED
@@ -427,6 +427,10 @@ Our plugin uses a cookie in order to function properly. It does not store person
427
  1. Go to Plugins -> Installed Plugins and click the 'Activate' link under the WordPress SiteGround Optimizer listing
428
 
429
  == Changelog ==
 
 
 
 
430
 
431
  = Version 7.2.0 =
432
  Release Date: July 14th, 2022
427
  1. Go to Plugins -> Installed Plugins and click the 'Activate' link under the WordPress SiteGround Optimizer listing
428
 
429
  == Changelog ==
430
+ = Version 7.2.1 =
431
+ Release Date: August 10th, 2022
432
+
433
+ * Improved Cloudflare detection
434
 
435
  = Version 7.2.0 =
436
  Release Date: July 14th, 2022
sg-cachepress.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: SiteGround Optimizer
11
  * Plugin URI: https://siteground.com
12
  * Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
13
- * Version: 7.2.0
14
  * Author: SiteGround
15
  * Author URI: https://www.siteground.com
16
  * Text Domain: sg-cachepress
@@ -32,7 +32,7 @@ if ( ! defined( 'WPINC' ) ) {
32
 
33
  // Define version constant.
34
  if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
35
- define( __NAMESPACE__ . '\VERSION', '7.2.0' );
36
  }
37
 
38
  // Define slug constant.
10
  * Plugin Name: SiteGround Optimizer
11
  * Plugin URI: https://siteground.com
12
  * Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
13
+ * Version: 7.2.1
14
  * Author: SiteGround
15
  * Author URI: https://www.siteground.com
16
  * Text Domain: sg-cachepress
32
 
33
  // Define version constant.
34
  if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
35
+ define( __NAMESPACE__ . '\VERSION', '7.2.1' );
36
  }
37
 
38
  // Define slug constant.
vendor/autoload.php CHANGED
@@ -2,11 +2,6 @@
2
 
3
  // autoload.php @generated by Composer
4
 
5
- if (PHP_VERSION_ID < 50600) {
6
- echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
7
- exit(1);
8
- }
9
-
10
  require_once __DIR__ . '/composer/autoload_real.php';
11
 
12
- return ComposerAutoloaderInit6aabfa86f466ba6438be5ac1658af064::getLoader();
2
 
3
  // autoload.php @generated by Composer
4
 
 
 
 
 
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit454419e965d59060fd765740e7825238::getLoader();
vendor/bin/minifycss CHANGED
@@ -1,117 +1,45 @@
1
  #!/usr/bin/env php
2
  <?php
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- /**
5
- * Proxy PHP file generated by Composer
6
- *
7
- * This file includes the referenced bin path (../matthiasmullie/minify/bin/minifycss)
8
- * using a stream wrapper to prevent the shebang from being output on PHP<8
9
- *
10
- * @generated
11
- */
12
-
13
- namespace Composer;
14
-
15
- $GLOBALS['_composer_bin_dir'] = __DIR__;
16
- $GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
17
-
18
- if (PHP_VERSION_ID < 80000) {
19
- if (!class_exists('Composer\BinProxyWrapper')) {
20
- /**
21
- * @internal
22
- */
23
- final class BinProxyWrapper
24
- {
25
- private $handle;
26
- private $position;
27
- private $realpath;
28
-
29
- public function stream_open($path, $mode, $options, &$opened_path)
30
- {
31
- // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
32
- $opened_path = substr($path, 17);
33
- $this->realpath = realpath($opened_path) ?: $opened_path;
34
- $opened_path = $this->realpath;
35
- $this->handle = fopen($this->realpath, $mode);
36
- $this->position = 0;
37
-
38
- return (bool) $this->handle;
39
- }
40
-
41
- public function stream_read($count)
42
- {
43
- $data = fread($this->handle, $count);
44
-
45
- if ($this->position === 0) {
46
- $data = preg_replace('{^#!.*\r?\n}', '', $data);
47
- }
48
-
49
- $this->position += strlen($data);
50
-
51
- return $data;
52
- }
53
-
54
- public function stream_cast($castAs)
55
- {
56
- return $this->handle;
57
- }
58
-
59
- public function stream_close()
60
- {
61
- fclose($this->handle);
62
- }
63
-
64
- public function stream_lock($operation)
65
- {
66
- return $operation ? flock($this->handle, $operation) : true;
67
- }
68
-
69
- public function stream_seek($offset, $whence)
70
- {
71
- if (0 === fseek($this->handle, $offset, $whence)) {
72
- $this->position = ftell($this->handle);
73
- return true;
74
- }
75
-
76
- return false;
77
- }
78
-
79
- public function stream_tell()
80
- {
81
- return $this->position;
82
- }
83
-
84
- public function stream_eof()
85
- {
86
- return feof($this->handle);
87
- }
88
-
89
- public function stream_stat()
90
- {
91
- return array();
92
- }
93
-
94
- public function stream_set_option($option, $arg1, $arg2)
95
- {
96
- return true;
97
- }
98
-
99
- public function url_stat($path, $flags)
100
- {
101
- $path = substr($path, 17);
102
- if (file_exists($path)) {
103
- return stat($path);
104
- }
105
-
106
- return false;
107
- }
108
- }
109
- }
110
-
111
- if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
112
- include("phpvfscomposer://" . __DIR__ . '/..'.'/matthiasmullie/minify/bin/minifycss');
113
- exit(0);
114
- }
115
  }
116
 
117
- include __DIR__ . '/..'.'/matthiasmullie/minify/bin/minifycss';
 
 
 
 
 
 
1
  #!/usr/bin/env php
2
  <?php
3
+ use MatthiasMullie\Minify;
4
+
5
+ // command line utility to minify CSS
6
+ if (file_exists(__DIR__ . '/../../../autoload.php')) {
7
+ // if composer install
8
+ require_once __DIR__ . '/../../../autoload.php';
9
+ } else {
10
+ require_once __DIR__ . '/../src/Minify.php';
11
+ require_once __DIR__ . '/../src/CSS.php';
12
+ require_once __DIR__ . '/../src/Exception.php';
13
+ }
14
 
15
+ error_reporting(E_ALL);
16
+ // check PHP setup for cli arguments
17
+ if (!isset($_SERVER['argv']) && !isset($argv)) {
18
+ fwrite(STDERR, 'Please enable the "register_argc_argv" directive in your php.ini' . PHP_EOL);
19
+ exit(1);
20
+ } elseif (!isset($argv)) {
21
+ $argv = $_SERVER['argv'];
22
+ }
23
+ // check if path to file given
24
+ if (!isset($argv[1])) {
25
+ fwrite(STDERR, 'Argument expected: path to file' . PHP_EOL);
26
+ exit(1);
27
+ }
28
+ // check if script run in cli environment
29
+ if ('cli' !== php_sapi_name()) {
30
+ fwrite(STDERR, $argv[1] . ' must be run in the command line' . PHP_EOL);
31
+ exit(1);
32
+ }
33
+ // check if source file exists
34
+ if (!file_exists($argv[1])) {
35
+ fwrite(STDERR, 'Source file "' . $argv[1] . '" not found' . PHP_EOL);
36
+ exit(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
+ try {
40
+ $minifier = new Minify\CSS($argv[1]);
41
+ echo $minifier->minify();
42
+ } catch (Exception $e) {
43
+ fwrite(STDERR, $e->getMessage(), PHP_EOL);
44
+ exit(1);
45
+ }
vendor/bin/minifyjs CHANGED
@@ -1,117 +1,45 @@
1
  #!/usr/bin/env php
2
  <?php
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- /**
5
- * Proxy PHP file generated by Composer
6
- *
7
- * This file includes the referenced bin path (../matthiasmullie/minify/bin/minifyjs)
8
- * using a stream wrapper to prevent the shebang from being output on PHP<8
9
- *
10
- * @generated
11
- */
12
-
13
- namespace Composer;
14
-
15
- $GLOBALS['_composer_bin_dir'] = __DIR__;
16
- $GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
17
-
18
- if (PHP_VERSION_ID < 80000) {
19
- if (!class_exists('Composer\BinProxyWrapper')) {
20
- /**
21
- * @internal
22
- */
23
- final class BinProxyWrapper
24
- {
25
- private $handle;
26
- private $position;
27
- private $realpath;
28
-
29
- public function stream_open($path, $mode, $options, &$opened_path)
30
- {
31
- // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
32
- $opened_path = substr($path, 17);
33
- $this->realpath = realpath($opened_path) ?: $opened_path;
34
- $opened_path = $this->realpath;
35
- $this->handle = fopen($this->realpath, $mode);
36
- $this->position = 0;
37
-
38
- return (bool) $this->handle;
39
- }
40
-
41
- public function stream_read($count)
42
- {
43
- $data = fread($this->handle, $count);
44
-
45
- if ($this->position === 0) {
46
- $data = preg_replace('{^#!.*\r?\n}', '', $data);
47
- }
48
-
49
- $this->position += strlen($data);
50
-
51
- return $data;
52
- }
53
-
54
- public function stream_cast($castAs)
55
- {
56
- return $this->handle;
57
- }
58
-
59
- public function stream_close()
60
- {
61
- fclose($this->handle);
62
- }
63
-
64
- public function stream_lock($operation)
65
- {
66
- return $operation ? flock($this->handle, $operation) : true;
67
- }
68
-
69
- public function stream_seek($offset, $whence)
70
- {
71
- if (0 === fseek($this->handle, $offset, $whence)) {
72
- $this->position = ftell($this->handle);
73
- return true;
74
- }
75
-
76
- return false;
77
- }
78
-
79
- public function stream_tell()
80
- {
81
- return $this->position;
82
- }
83
-
84
- public function stream_eof()
85
- {
86
- return feof($this->handle);
87
- }
88
-
89
- public function stream_stat()
90
- {
91
- return array();
92
- }
93
-
94
- public function stream_set_option($option, $arg1, $arg2)
95
- {
96
- return true;
97
- }
98
-
99
- public function url_stat($path, $flags)
100
- {
101
- $path = substr($path, 17);
102
- if (file_exists($path)) {
103
- return stat($path);
104
- }
105
-
106
- return false;
107
- }
108
- }
109
- }
110
-
111
- if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
112
- include("phpvfscomposer://" . __DIR__ . '/..'.'/matthiasmullie/minify/bin/minifyjs');
113
- exit(0);
114
- }
115
  }
116
 
117
- include __DIR__ . '/..'.'/matthiasmullie/minify/bin/minifyjs';
 
 
 
 
 
 
1
  #!/usr/bin/env php
2
  <?php
3
+ use MatthiasMullie\Minify;
4
+
5
+ // command line utility to minify JS
6
+ if (file_exists(__DIR__ . '/../../../autoload.php')) {
7
+ // if composer install
8
+ require_once __DIR__ . '/../../../autoload.php';
9
+ } else {
10
+ require_once __DIR__ . '/../src/Minify.php';
11
+ require_once __DIR__ . '/../src/JS.php';
12
+ require_once __DIR__ . '/../src/Exception.php';
13
+ }
14
 
15
+ error_reporting(E_ALL);
16
+ // check PHP setup for cli arguments
17
+ if (!isset($_SERVER['argv']) && !isset($argv)) {
18
+ fwrite(STDERR, 'Please enable the "register_argc_argv" directive in your php.ini' . PHP_EOL);
19
+ exit(1);
20
+ } elseif (!isset($argv)) {
21
+ $argv = $_SERVER['argv'];
22
+ }
23
+ // check if path to file given
24
+ if (!isset($argv[1])) {
25
+ fwrite(STDERR, 'Argument expected: path to file' . PHP_EOL);
26
+ exit(1);
27
+ }
28
+ // check if script run in cli environment
29
+ if ('cli' !== php_sapi_name()) {
30
+ fwrite(STDERR, $argv[1] . ' must be run in the command line' . PHP_EOL);
31
+ exit(1);
32
+ }
33
+ // check if source file exists
34
+ if (!file_exists($argv[1])) {
35
+ fwrite(STDERR, 'Source file "' . $argv[1] . '" not found' . PHP_EOL);
36
+ exit(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
+ try {
40
+ $minifier = new Minify\JS($argv[1]);
41
+ echo $minifier->minify();
42
+ } catch (Exception $e) {
43
+ fwrite(STDERR, $e->getMessage(), PHP_EOL);
44
+ exit(1);
45
+ }
vendor/composer/ClassLoader.php CHANGED
@@ -42,75 +42,30 @@ namespace Composer\Autoload;
42
  */
43
  class ClassLoader
44
  {
45
- /** @var ?string */
46
  private $vendorDir;
47
 
48
  // PSR-4
49
- /**
50
- * @var array[]
51
- * @psalm-var array<string, array<string, int>>
52
- */
53
  private $prefixLengthsPsr4 = array();
54
- /**
55
- * @var array[]
56
- * @psalm-var array<string, array<int, string>>
57
- */
58
  private $prefixDirsPsr4 = array();
59
- /**
60
- * @var array[]
61
- * @psalm-var array<string, string>
62
- */
63
  private $fallbackDirsPsr4 = array();
64
 
65
  // PSR-0
66
- /**
67
- * @var array[]
68
- * @psalm-var array<string, array<string, string[]>>
69
- */
70
  private $prefixesPsr0 = array();
71
- /**
72
- * @var array[]
73
- * @psalm-var array<string, string>
74
- */
75
  private $fallbackDirsPsr0 = array();
76
 
77
- /** @var bool */
78
  private $useIncludePath = false;
79
-
80
- /**
81
- * @var string[]
82
- * @psalm-var array<string, string>
83
- */
84
  private $classMap = array();
85
-
86
- /** @var bool */
87
  private $classMapAuthoritative = false;
88
-
89
- /**
90
- * @var bool[]
91
- * @psalm-var array<string, bool>
92
- */
93
  private $missingClasses = array();
94
-
95
- /** @var ?string */
96
  private $apcuPrefix;
97
 
98
- /**
99
- * @var self[]
100
- */
101
  private static $registeredLoaders = array();
102
 
103
- /**
104
- * @param ?string $vendorDir
105
- */
106
  public function __construct($vendorDir = null)
107
  {
108
  $this->vendorDir = $vendorDir;
109
  }
110
 
111
- /**
112
- * @return string[]
113
- */
114
  public function getPrefixes()
115
  {
116
  if (!empty($this->prefixesPsr0)) {
@@ -120,47 +75,28 @@ class ClassLoader
120
  return array();
121
  }
122
 
123
- /**
124
- * @return array[]
125
- * @psalm-return array<string, array<int, string>>
126
- */
127
  public function getPrefixesPsr4()
128
  {
129
  return $this->prefixDirsPsr4;
130
  }
131
 
132
- /**
133
- * @return array[]
134
- * @psalm-return array<string, string>
135
- */
136
  public function getFallbackDirs()
137
  {
138
  return $this->fallbackDirsPsr0;
139
  }
140
 
141
- /**
142
- * @return array[]
143
- * @psalm-return array<string, string>
144
- */
145
  public function getFallbackDirsPsr4()
146
  {
147
  return $this->fallbackDirsPsr4;
148
  }
149
 
150
- /**
151
- * @return string[] Array of classname => path
152
- * @psalm-return array<string, string>
153
- */
154
  public function getClassMap()
155
  {
156
  return $this->classMap;
157
  }
158
 
159
  /**
160
- * @param string[] $classMap Class to filename map
161
- * @psalm-param array<string, string> $classMap
162
- *
163
- * @return void
164
  */
165
  public function addClassMap(array $classMap)
166
  {
@@ -175,11 +111,9 @@ class ClassLoader
175
  * Registers a set of PSR-0 directories for a given prefix, either
176
  * appending or prepending to the ones previously set for this prefix.
177
  *
178
- * @param string $prefix The prefix
179
- * @param string[]|string $paths The PSR-0 root directories
180
- * @param bool $prepend Whether to prepend the directories
181
- *
182
- * @return void
183
  */
184
  public function add($prefix, $paths, $prepend = false)
185
  {
@@ -222,13 +156,11 @@ class ClassLoader
222
  * Registers a set of PSR-4 directories for a given namespace, either
223
  * appending or prepending to the ones previously set for this namespace.
224
  *
225
- * @param string $prefix The prefix/namespace, with trailing '\\'
226
- * @param string[]|string $paths The PSR-4 base directories
227
- * @param bool $prepend Whether to prepend the directories
228
  *
229
  * @throws \InvalidArgumentException
230
- *
231
- * @return void
232
  */
233
  public function addPsr4($prefix, $paths, $prepend = false)
234
  {
@@ -272,10 +204,8 @@ class ClassLoader
272
  * Registers a set of PSR-0 directories for a given prefix,
273
  * replacing any others previously set for this prefix.
274
  *
275
- * @param string $prefix The prefix
276
- * @param string[]|string $paths The PSR-0 base directories
277
- *
278
- * @return void
279
  */
280
  public function set($prefix, $paths)
281
  {
@@ -290,12 +220,10 @@ class ClassLoader
290
  * Registers a set of PSR-4 directories for a given namespace,
291
  * replacing any others previously set for this namespace.
292
  *
293
- * @param string $prefix The prefix/namespace, with trailing '\\'
294
- * @param string[]|string $paths The PSR-4 base directories
295
  *
296
  * @throws \InvalidArgumentException
297
- *
298
- * @return void
299
  */
300
  public function setPsr4($prefix, $paths)
301
  {
@@ -315,8 +243,6 @@ class ClassLoader
315
  * Turns on searching the include path for class files.
316
  *
317
  * @param bool $useIncludePath
318
- *
319
- * @return void
320
  */
321
  public function setUseIncludePath($useIncludePath)
322
  {
@@ -339,8 +265,6 @@ class ClassLoader
339
  * that have not been registered with the class map.
340
  *
341
  * @param bool $classMapAuthoritative
342
- *
343
- * @return void
344
  */
345
  public function setClassMapAuthoritative($classMapAuthoritative)
346
  {
@@ -361,8 +285,6 @@ class ClassLoader
361
  * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
362
  *
363
  * @param string|null $apcuPrefix
364
- *
365
- * @return void
366
  */
367
  public function setApcuPrefix($apcuPrefix)
368
  {
@@ -383,8 +305,6 @@ class ClassLoader
383
  * Registers this instance as an autoloader.
384
  *
385
  * @param bool $prepend Whether to prepend the autoloader or not
386
- *
387
- * @return void
388
  */
389
  public function register($prepend = false)
390
  {
@@ -404,8 +324,6 @@ class ClassLoader
404
 
405
  /**
406
  * Unregisters this instance as an autoloader.
407
- *
408
- * @return void
409
  */
410
  public function unregister()
411
  {
@@ -485,11 +403,6 @@ class ClassLoader
485
  return self::$registeredLoaders;
486
  }
487
 
488
- /**
489
- * @param string $class
490
- * @param string $ext
491
- * @return string|false
492
- */
493
  private function findFileWithExtension($class, $ext)
494
  {
495
  // PSR-4 lookup
@@ -561,10 +474,6 @@ class ClassLoader
561
  * Scope isolated include.
562
  *
563
  * Prevents access to $this/self from included files.
564
- *
565
- * @param string $file
566
- * @return void
567
- * @private
568
  */
569
  function includeFile($file)
570
  {
42
  */
43
  class ClassLoader
44
  {
 
45
  private $vendorDir;
46
 
47
  // PSR-4
 
 
 
 
48
  private $prefixLengthsPsr4 = array();
 
 
 
 
49
  private $prefixDirsPsr4 = array();
 
 
 
 
50
  private $fallbackDirsPsr4 = array();
51
 
52
  // PSR-0
 
 
 
 
53
  private $prefixesPsr0 = array();
 
 
 
 
54
  private $fallbackDirsPsr0 = array();
55
 
 
56
  private $useIncludePath = false;
 
 
 
 
 
57
  private $classMap = array();
 
 
58
  private $classMapAuthoritative = false;
 
 
 
 
 
59
  private $missingClasses = array();
 
 
60
  private $apcuPrefix;
61
 
 
 
 
62
  private static $registeredLoaders = array();
63
 
 
 
 
64
  public function __construct($vendorDir = null)
65
  {
66
  $this->vendorDir = $vendorDir;
67
  }
68
 
 
 
 
69
  public function getPrefixes()
70
  {
71
  if (!empty($this->prefixesPsr0)) {
75
  return array();
76
  }
77
 
 
 
 
 
78
  public function getPrefixesPsr4()
79
  {
80
  return $this->prefixDirsPsr4;
81
  }
82
 
 
 
 
 
83
  public function getFallbackDirs()
84
  {
85
  return $this->fallbackDirsPsr0;
86
  }
87
 
 
 
 
 
88
  public function getFallbackDirsPsr4()
89
  {
90
  return $this->fallbackDirsPsr4;
91
  }
92
 
 
 
 
 
93
  public function getClassMap()
94
  {
95
  return $this->classMap;
96
  }
97
 
98
  /**
99
+ * @param array $classMap Class to filename map
 
 
 
100
  */
101
  public function addClassMap(array $classMap)
102
  {
111
  * Registers a set of PSR-0 directories for a given prefix, either
112
  * appending or prepending to the ones previously set for this prefix.
113
  *
114
+ * @param string $prefix The prefix
115
+ * @param array|string $paths The PSR-0 root directories
116
+ * @param bool $prepend Whether to prepend the directories
 
 
117
  */
118
  public function add($prefix, $paths, $prepend = false)
119
  {
156
  * Registers a set of PSR-4 directories for a given namespace, either
157
  * appending or prepending to the ones previously set for this namespace.
158
  *
159
+ * @param string $prefix The prefix/namespace, with trailing '\\'
160
+ * @param array|string $paths The PSR-4 base directories
161
+ * @param bool $prepend Whether to prepend the directories
162
  *
163
  * @throws \InvalidArgumentException
 
 
164
  */
165
  public function addPsr4($prefix, $paths, $prepend = false)
166
  {
204
  * Registers a set of PSR-0 directories for a given prefix,
205
  * replacing any others previously set for this prefix.
206
  *
207
+ * @param string $prefix The prefix
208
+ * @param array|string $paths The PSR-0 base directories
 
 
209
  */
210
  public function set($prefix, $paths)
211
  {
220
  * Registers a set of PSR-4 directories for a given namespace,
221
  * replacing any others previously set for this namespace.
222
  *
223
+ * @param string $prefix The prefix/namespace, with trailing '\\'
224
+ * @param array|string $paths The PSR-4 base directories
225
  *
226
  * @throws \InvalidArgumentException
 
 
227
  */
228
  public function setPsr4($prefix, $paths)
229
  {
243
  * Turns on searching the include path for class files.
244
  *
245
  * @param bool $useIncludePath
 
 
246
  */
247
  public function setUseIncludePath($useIncludePath)
248
  {
265
  * that have not been registered with the class map.
266
  *
267
  * @param bool $classMapAuthoritative
 
 
268
  */
269
  public function setClassMapAuthoritative($classMapAuthoritative)
270
  {
285
  * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
286
  *
287
  * @param string|null $apcuPrefix
 
 
288
  */
289
  public function setApcuPrefix($apcuPrefix)
290
  {
305
  * Registers this instance as an autoloader.
306
  *
307
  * @param bool $prepend Whether to prepend the autoloader or not
 
 
308
  */
309
  public function register($prepend = false)
310
  {
324
 
325
  /**
326
  * Unregisters this instance as an autoloader.
 
 
327
  */
328
  public function unregister()
329
  {
403
  return self::$registeredLoaders;
404
  }
405
 
 
 
 
 
 
406
  private function findFileWithExtension($class, $ext)
407
  {
408
  // PSR-4 lookup
474
  * Scope isolated include.
475
  *
476
  * Prevents access to $this/self from included files.
 
 
 
 
477
  */
478
  function includeFile($file)
479
  {
vendor/composer/InstalledVersions.php CHANGED
@@ -20,27 +20,12 @@ use Composer\Semver\VersionParser;
20
  *
21
  * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22
  *
23
- * To require its presence, you can require `composer-runtime-api ^2.0`
24
- *
25
- * @final
26
  */
27
  class InstalledVersions
28
  {
29
- /**
30
- * @var mixed[]|null
31
- * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
32
- */
33
  private static $installed;
34
-
35
- /**
36
- * @var bool|null
37
- */
38
  private static $canGetVendors;
39
-
40
- /**
41
- * @var array[]
42
- * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
43
- */
44
  private static $installedByVendor = array();
45
 
46
  /**
@@ -243,7 +228,7 @@ class InstalledVersions
243
 
244
  /**
245
  * @return array
246
- * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
247
  */
248
  public static function getRootPackage()
249
  {
@@ -257,7 +242,7 @@ class InstalledVersions
257
  *
258
  * @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.
259
  * @return array[]
260
- * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
261
  */
262
  public static function getRawData()
263
  {
@@ -280,7 +265,7 @@ class InstalledVersions
280
  * Returns the raw data of all installed.php which are currently loaded for custom implementations
281
  *
282
  * @return array[]
283
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
284
  */
285
  public static function getAllRawData()
286
  {
@@ -303,7 +288,7 @@ class InstalledVersions
303
  * @param array[] $data A vendor/composer/installed.php data set
304
  * @return void
305
  *
306
- * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
307
  */
308
  public static function reload($data)
309
  {
@@ -313,7 +298,7 @@ class InstalledVersions
313
 
314
  /**
315
  * @return array[]
316
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
317
  */
318
  private static function getInstalled()
319
  {
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
  /**
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
  {
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
  {
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
  {
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
  {
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
  {
vendor/composer/autoload_classmap.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_classmap.php @generated by Composer
4
 
5
- $vendorDir = dirname(__DIR__);
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
2
 
3
  // autoload_classmap.php @generated by Composer
4
 
5
+ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
vendor/composer/autoload_files.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_files.php @generated by Composer
4
 
5
- $vendorDir = dirname(__DIR__);
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
2
 
3
  // autoload_files.php @generated by Composer
4
 
5
+ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
vendor/composer/autoload_namespaces.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_namespaces.php @generated by Composer
4
 
5
- $vendorDir = dirname(__DIR__);
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
2
 
3
  // autoload_namespaces.php @generated by Composer
4
 
5
+ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
vendor/composer/autoload_psr4.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_psr4.php @generated by Composer
4
 
5
- $vendorDir = dirname(__DIR__);
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
2
 
3
  // autoload_psr4.php @generated by Composer
4
 
5
+ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit6aabfa86f466ba6438be5ac1658af064
6
  {
7
  private static $loader;
8
 
@@ -24,34 +24,52 @@ class ComposerAutoloaderInit6aabfa86f466ba6438be5ac1658af064
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
- spl_autoload_register(array('ComposerAutoloaderInit6aabfa86f466ba6438be5ac1658af064', 'loadClassLoader'), true, true);
28
- self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
- spl_autoload_unregister(array('ComposerAutoloaderInit6aabfa86f466ba6438be5ac1658af064', 'loadClassLoader'));
30
 
31
- require __DIR__ . '/autoload_static.php';
32
- call_user_func(\Composer\Autoload\ComposerStaticInit6aabfa86f466ba6438be5ac1658af064::getInitializer($loader));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  $loader->register(true);
35
 
36
- $includeFiles = \Composer\Autoload\ComposerStaticInit6aabfa86f466ba6438be5ac1658af064::$files;
 
 
 
 
37
  foreach ($includeFiles as $fileIdentifier => $file) {
38
- composerRequire6aabfa86f466ba6438be5ac1658af064($fileIdentifier, $file);
39
  }
40
 
41
  return $loader;
42
  }
43
  }
44
 
45
- /**
46
- * @param string $fileIdentifier
47
- * @param string $file
48
- * @return void
49
- */
50
- function composerRequire6aabfa86f466ba6438be5ac1658af064($fileIdentifier, $file)
51
  {
52
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
53
- $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
54
-
55
  require $file;
 
 
56
  }
57
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit454419e965d59060fd765740e7825238
6
  {
7
  private static $loader;
8
 
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
+ spl_autoload_register(array('ComposerAutoloaderInit454419e965d59060fd765740e7825238', 'loadClassLoader'), true, true);
28
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
29
+ spl_autoload_unregister(array('ComposerAutoloaderInit454419e965d59060fd765740e7825238', '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\ComposerStaticInit454419e965d59060fd765740e7825238::getInitializer($loader));
36
+ } else {
37
+ $map = require __DIR__ . '/autoload_namespaces.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->set($namespace, $path);
40
+ }
41
+
42
+ $map = require __DIR__ . '/autoload_psr4.php';
43
+ foreach ($map as $namespace => $path) {
44
+ $loader->setPsr4($namespace, $path);
45
+ }
46
+
47
+ $classMap = require __DIR__ . '/autoload_classmap.php';
48
+ if ($classMap) {
49
+ $loader->addClassMap($classMap);
50
+ }
51
+ }
52
 
53
  $loader->register(true);
54
 
55
+ if ($useStaticLoader) {
56
+ $includeFiles = Composer\Autoload\ComposerStaticInit454419e965d59060fd765740e7825238::$files;
57
+ } else {
58
+ $includeFiles = require __DIR__ . '/autoload_files.php';
59
+ }
60
  foreach ($includeFiles as $fileIdentifier => $file) {
61
+ composerRequire454419e965d59060fd765740e7825238($fileIdentifier, $file);
62
  }
63
 
64
  return $loader;
65
  }
66
  }
67
 
68
+ function composerRequire454419e965d59060fd765740e7825238($fileIdentifier, $file)
 
 
 
 
 
69
  {
70
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
 
 
71
  require $file;
72
+
73
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
74
  }
75
  }
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit6aabfa86f466ba6438be5ac1658af064
8
  {
9
  public static $files = array (
10
  '7135897415a2b76322abd22e8fdd66f8' => __DIR__ . '/../..' . '/helpers/helpers.php',
@@ -96,10 +96,10 @@ class ComposerStaticInit6aabfa86f466ba6438be5ac1658af064
96
  public static function getInitializer(ClassLoader $loader)
97
  {
98
  return \Closure::bind(function () use ($loader) {
99
- $loader->prefixLengthsPsr4 = ComposerStaticInit6aabfa86f466ba6438be5ac1658af064::$prefixLengthsPsr4;
100
- $loader->prefixDirsPsr4 = ComposerStaticInit6aabfa86f466ba6438be5ac1658af064::$prefixDirsPsr4;
101
- $loader->prefixesPsr0 = ComposerStaticInit6aabfa86f466ba6438be5ac1658af064::$prefixesPsr0;
102
- $loader->classMap = ComposerStaticInit6aabfa86f466ba6438be5ac1658af064::$classMap;
103
 
104
  }, null, ClassLoader::class);
105
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit454419e965d59060fd765740e7825238
8
  {
9
  public static $files = array (
10
  '7135897415a2b76322abd22e8fdd66f8' => __DIR__ . '/../..' . '/helpers/helpers.php',
96
  public static function getInitializer(ClassLoader $loader)
97
  {
98
  return \Closure::bind(function () use ($loader) {
99
+ $loader->prefixLengthsPsr4 = ComposerStaticInit454419e965d59060fd765740e7825238::$prefixLengthsPsr4;
100
+ $loader->prefixDirsPsr4 = ComposerStaticInit454419e965d59060fd765740e7825238::$prefixDirsPsr4;
101
+ $loader->prefixesPsr0 = ComposerStaticInit454419e965d59060fd765740e7825238::$prefixesPsr0;
102
+ $loader->classMap = ComposerStaticInit454419e965d59060fd765740e7825238::$classMap;
103
 
104
  }, null, ClassLoader::class);
105
  }
vendor/composer/installed.json CHANGED
@@ -346,12 +346,9 @@
346
  "source": {
347
  "type": "git",
348
  "url": "git@gitlab.siteground.com:wordpress/siteground-data.git",
349
- "reference": "8c6d89492847e43aeef2d5d0cb8860aa1e0220c3"
350
  },
351
- "require": {
352
- "siteground/siteground-helper": "master@dev"
353
- },
354
- "time": "2022-07-14T12:26:29+00:00",
355
  "default-branch": true,
356
  "type": "library",
357
  "installation-source": "source",
346
  "source": {
347
  "type": "git",
348
  "url": "git@gitlab.siteground.com:wordpress/siteground-data.git",
349
+ "reference": "58ba53b8a5711c0cd33be62ebedf99cc2ec180ec"
350
  },
351
+ "time": "2022-06-09T12:55:21+00:00",
 
 
 
352
  "default-branch": true,
353
  "type": "library",
354
  "installation-source": "source",
vendor/composer/installed.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php return array(
2
  'root' => array(
3
- 'pretty_version' => 'dev-develop',
4
- 'version' => 'dev-develop',
5
  'type' => 'wordpress-plugin',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => 'c4aa4c715d9278b29339fa0e8025f3d21d36b9a1',
9
  'name' => 'siteground/sg-cachepress',
10
  'dev' => true,
11
  ),
@@ -67,12 +67,12 @@
67
  'dev_requirement' => false,
68
  ),
69
  'siteground/sg-cachepress' => array(
70
- 'pretty_version' => 'dev-develop',
71
- 'version' => 'dev-develop',
72
  'type' => 'wordpress-plugin',
73
  'install_path' => __DIR__ . '/../../',
74
  'aliases' => array(),
75
- 'reference' => 'c4aa4c715d9278b29339fa0e8025f3d21d36b9a1',
76
  'dev_requirement' => false,
77
  ),
78
  'siteground/siteground-data' => array(
@@ -83,7 +83,7 @@
83
  'aliases' => array(
84
  0 => '9999999-dev',
85
  ),
86
- 'reference' => '8c6d89492847e43aeef2d5d0cb8860aa1e0220c3',
87
  'dev_requirement' => false,
88
  ),
89
  'siteground/siteground-emails' => array(
1
  <?php return array(
2
  'root' => array(
3
+ 'pretty_version' => 'dev-master',
4
+ 'version' => 'dev-master',
5
  'type' => 'wordpress-plugin',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => 'eca681d69253003d423ddfccef2a3eb663b3a006',
9
  'name' => 'siteground/sg-cachepress',
10
  'dev' => true,
11
  ),
67
  'dev_requirement' => false,
68
  ),
69
  'siteground/sg-cachepress' => array(
70
+ 'pretty_version' => 'dev-master',
71
+ 'version' => 'dev-master',
72
  'type' => 'wordpress-plugin',
73
  'install_path' => __DIR__ . '/../../',
74
  'aliases' => array(),
75
+ 'reference' => 'eca681d69253003d423ddfccef2a3eb663b3a006',
76
  'dev_requirement' => false,
77
  ),
78
  'siteground/siteground-data' => array(
83
  'aliases' => array(
84
  0 => '9999999-dev',
85
  ),
86
+ 'reference' => '58ba53b8a5711c0cd33be62ebedf99cc2ec180ec',
87
  'dev_requirement' => false,
88
  ),
89
  'siteground/siteground-emails' => array(
vendor/pear.zip ADDED
Binary file
vendor/siteground/siteground-helper/src/Helper_Service.php CHANGED
@@ -194,4 +194,59 @@ class Helper_Service {
194
 
195
  return (int) ( @file_exists( '/etc/yum.repos.d/baseos.repo' ) && @file_exists( '/Z' ) );
196
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  }
194
 
195
  return (int) ( @file_exists( '/etc/yum.repos.d/baseos.repo' ) && @file_exists( '/Z' ) );
196
  }
197
+
198
+ /**
199
+ * Encrypt data method.
200
+ *
201
+ * @since 1.0.1
202
+ *
203
+ * @param string $data The string we will encrypt.
204
+ * @param string $key The string used for encryption key.
205
+ *
206
+ * @return string The encrypted data.
207
+ */
208
+ public static function sgs_encrypt( $data, $key ) {
209
+ // Remove the base64 encoding from our key.
210
+ $encryption_key = base64_decode( $key . AUTH_SALT );
211
+
212
+ // Define cipher and generate an initialization vector.
213
+ $cipher = 'AES-256-CBC';
214
+ $ivlen = openssl_cipher_iv_length( $cipher );
215
+ $iv = openssl_random_pseudo_bytes( $ivlen );
216
+
217
+ $raw_value = openssl_encrypt( implode( '|', $data ), $cipher, $encryption_key, OPENSSL_RAW_DATA, $iv );
218
+
219
+ // Return the encrypted data.
220
+ return base64_encode( $iv . $raw_value );
221
+ }
222
+
223
+ /**
224
+ * Decrypt data method.
225
+ *
226
+ * @since 1.0.1
227
+ *
228
+ * @param string $data The string we will decrypt.
229
+ * @param string $key The string used as an encryption key.
230
+ *
231
+ * @return string The decrypted data.
232
+ */
233
+ public static function sgs_decrypt( $data, $key ) {
234
+ // Remove the base64 encoding from our data.
235
+ $raw_value = base64_decode( $data, true );
236
+
237
+ // Remove the base64 encoding from our key.
238
+ $encryption_key = base64_decode( $key . AUTH_SALT );
239
+
240
+ // Define cipher and get the initialization vector.
241
+ $cipher = 'AES-256-CBC';
242
+ $ivlen = openssl_cipher_iv_length( $cipher );
243
+ $iv = substr( $raw_value, 0, $ivlen );
244
+
245
+ $raw_value = substr( $raw_value, $ivlen );
246
+
247
+ // Return the decrypted data.
248
+ $decrypted = openssl_decrypt( $raw_value, 'AES-256-CBC', $encryption_key, OPENSSL_RAW_DATA, $iv );
249
+
250
+ return explode( '|', $decrypted );
251
+ }
252
  }