Version Description
Download this release
Release Info
Developer | sstoqnov |
Plugin | SG Optimizer |
Version | 5.0.9 |
Comparing to | |
See all releases |
Code changes from version 5.0.8 to 5.0.9
- core/Activator/Activator.php +30 -0
- core/Admin/Admin_Bar.php +1 -0
- core/Deactivator/Deactivator.php +23 -0
- core/Htaccess/Htaccess.php +3 -3
- core/Install_Service/Install_5_0_9.php +34 -0
- core/Install_Service/Install_Service.php +3 -0
- core/Supercacher/Supercacher.php +1 -3
- readme.txt +5 -0
- sg-cachepress.php +6 -1
- templates/memcached.tpl +30 -52
core/Activator/Activator.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace SiteGround_Optimizer\Activator;
|
3 |
+
|
4 |
+
use SiteGround_Optimizer\Memcache\Memcache;
|
5 |
+
use SiteGround_Optimizer\Options\Options;
|
6 |
+
|
7 |
+
class Activator {
|
8 |
+
/**
|
9 |
+
* Run on plugin activation.
|
10 |
+
*
|
11 |
+
* @since 5.0.9
|
12 |
+
*/
|
13 |
+
public function activate() {
|
14 |
+
$this->maybe_create_memcache_dropin();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Check if memcache options was enabled and create the memcache dropin.
|
19 |
+
*
|
20 |
+
* @since 5.0.9
|
21 |
+
*/
|
22 |
+
public function maybe_create_memcache_dropin() {
|
23 |
+
if ( Options::is_enabled( 'siteground_optimizer_enable_memcached' ) ) {
|
24 |
+
$memcached = new Memcache();
|
25 |
+
$memcached->remove_memcached_dropin();
|
26 |
+
$memcached->create_memcached_dropin();
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
core/Admin/Admin_Bar.php
CHANGED
@@ -57,6 +57,7 @@ class Admin_Bar {
|
|
57 |
}
|
58 |
|
59 |
Supercacher::purge_cache();
|
|
|
60 |
|
61 |
wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
|
62 |
exit;
|
57 |
}
|
58 |
|
59 |
Supercacher::purge_cache();
|
60 |
+
Supercacher::flush_memcache();
|
61 |
|
62 |
wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
|
63 |
exit;
|
core/Deactivator/Deactivator.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace SiteGround_Optimizer\Deactivator;
|
3 |
+
|
4 |
+
use SiteGround_Optimizer\Memcache\Memcache;
|
5 |
+
use SiteGround_Optimizer\Options\Options;
|
6 |
+
use SiteGround_Optimizer\Supercacher\Supercacher;
|
7 |
+
|
8 |
+
class Deactivator {
|
9 |
+
/**
|
10 |
+
* Run on plugin deactivation.
|
11 |
+
*
|
12 |
+
* @since 5.0.5
|
13 |
+
*/
|
14 |
+
public function deactivate() {
|
15 |
+
$memcached = new Memcache();
|
16 |
+
$memcached->remove_memcached_dropin();
|
17 |
+
|
18 |
+
// Flush dynamic and memcache.
|
19 |
+
Supercacher::purge_cache();
|
20 |
+
Supercacher::flush_memcache();
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
core/Htaccess/Htaccess.php
CHANGED
@@ -56,9 +56,9 @@ class Htaccess {
|
|
56 |
'disable_all' => '/\#\s+Leverage Browser Caching by SG-Optimizer(.+?)\#\s+END\s+LBC\n|<IfModule mod_expires\.c>(.*?\n?)(<\/IfModule>\n\s)?<\/IfModule>/ims',
|
57 |
),
|
58 |
'ssl' => array(
|
59 |
-
'enabled'
|
60 |
-
'disabled'
|
61 |
-
'
|
62 |
),
|
63 |
'php' => array(
|
64 |
'enabled' => '/START PHP VERSION CHANGE forced by SG Optimizer/si',
|
56 |
'disable_all' => '/\#\s+Leverage Browser Caching by SG-Optimizer(.+?)\#\s+END\s+LBC\n|<IfModule mod_expires\.c>(.*?\n?)(<\/IfModule>\n\s)?<\/IfModule>/ims',
|
57 |
),
|
58 |
'ssl' => array(
|
59 |
+
'enabled' => '/HTTPS forced by SG-Optimizer/si',
|
60 |
+
'disabled' => '/\#\s+HTTPS\s+forced\s+by\s+SG-Optimizer(.+?)\#\s+END\s+HTTPS(\n)?/ims',
|
61 |
+
'disable_all' => '/\#\s+HTTPS\s+forced\s+by\s+SG-Optimizer(.+?)\#\s+END\s+HTTPS(\n)?/ims',
|
62 |
),
|
63 |
'php' => array(
|
64 |
'enabled' => '/START PHP VERSION CHANGE forced by SG Optimizer/si',
|
core/Install_Service/Install_5_0_9.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace SiteGround_Optimizer\Install_Service;
|
3 |
+
|
4 |
+
use SiteGround_Optimizer\Memcache\Memcache;
|
5 |
+
use SiteGround_Optimizer\Options\Options;
|
6 |
+
|
7 |
+
class Install_5_0_9 extends Install {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* The default install version. Overridden by the installation packages.
|
11 |
+
*
|
12 |
+
* @since 5.0.9
|
13 |
+
*
|
14 |
+
* @access protected
|
15 |
+
*
|
16 |
+
* @var string $version The install version.
|
17 |
+
*/
|
18 |
+
protected static $version = '5.0.9';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Run the install procedure.
|
22 |
+
*
|
23 |
+
* @since 5.0.9
|
24 |
+
*/
|
25 |
+
public function install() {
|
26 |
+
|
27 |
+
if ( Options::is_enabled( 'siteground_optimizer_enable_memcached' ) ) {
|
28 |
+
$memcached = new Memcache();
|
29 |
+
$memcached->remove_memcached_dropin();
|
30 |
+
$memcached->create_memcached_dropin();
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
core/Install_Service/Install_Service.php
CHANGED
@@ -6,6 +6,7 @@ use SiteGround_Optimizer\Install_Service\Install_5_0_0;
|
|
6 |
use SiteGround_Optimizer\Install_Service\Install_5_0_5;
|
7 |
use SiteGround_Optimizer\Install_Service\Install_5_0_6;
|
8 |
use SiteGround_Optimizer\Install_Service\Install_5_0_8;
|
|
|
9 |
use SiteGround_Optimizer\Supercacher\Supercacher;
|
10 |
|
11 |
/**
|
@@ -49,6 +50,7 @@ class Install_Service {
|
|
49 |
new Install_5_0_5(),
|
50 |
new Install_5_0_6(),
|
51 |
new Install_5_0_8(),
|
|
|
52 |
);
|
53 |
|
54 |
$version = null;
|
@@ -68,6 +70,7 @@ class Install_Service {
|
|
68 |
|
69 |
// Flush dynamic and memcache.
|
70 |
Supercacher::purge_cache();
|
|
|
71 |
}
|
72 |
}
|
73 |
}
|
6 |
use SiteGround_Optimizer\Install_Service\Install_5_0_5;
|
7 |
use SiteGround_Optimizer\Install_Service\Install_5_0_6;
|
8 |
use SiteGround_Optimizer\Install_Service\Install_5_0_8;
|
9 |
+
use SiteGround_Optimizer\Install_Service\Install_5_0_9;
|
10 |
use SiteGround_Optimizer\Supercacher\Supercacher;
|
11 |
|
12 |
/**
|
50 |
new Install_5_0_5(),
|
51 |
new Install_5_0_6(),
|
52 |
new Install_5_0_8(),
|
53 |
+
new Install_5_0_9(),
|
54 |
);
|
55 |
|
56 |
$version = null;
|
70 |
|
71 |
// Flush dynamic and memcache.
|
72 |
Supercacher::purge_cache();
|
73 |
+
Supercacher::flush_memcache();
|
74 |
}
|
75 |
}
|
76 |
}
|
core/Supercacher/Supercacher.php
CHANGED
@@ -147,7 +147,7 @@ class Supercacher {
|
|
147 |
* @return bool True on success, false on failure.
|
148 |
*/
|
149 |
public function purge_index_cache() {
|
150 |
-
return $this->purge_cache_request( get_home_url( '/' ),
|
151 |
}
|
152 |
|
153 |
/**
|
@@ -207,8 +207,6 @@ class Supercacher {
|
|
207 |
|
208 |
fclose( $cache_server_socket );
|
209 |
|
210 |
-
// Flush the memcache.
|
211 |
-
self::flush_memcache();
|
212 |
return preg_match( '/200/', $response );
|
213 |
}
|
214 |
|
147 |
* @return bool True on success, false on failure.
|
148 |
*/
|
149 |
public function purge_index_cache() {
|
150 |
+
return $this->purge_cache_request( get_home_url( '/' ), true );
|
151 |
}
|
152 |
|
153 |
/**
|
207 |
|
208 |
fclose( $cache_server_socket );
|
209 |
|
|
|
|
|
210 |
return preg_match( '/200/', $response );
|
211 |
}
|
212 |
|
readme.txt
CHANGED
@@ -101,6 +101,11 @@ Our plugin uses a cookie in order to function properly. It does not store person
|
|
101 |
|
102 |
== Changelog ==
|
103 |
|
|
|
|
|
|
|
|
|
|
|
104 |
= Version 5.0.8 =
|
105 |
* Better .htaccess handling when disabling and enabling Browser Cache and Gzip
|
106 |
* Improved image optimization handling
|
101 |
|
102 |
== Changelog ==
|
103 |
|
104 |
+
= Version 5.0.9 =
|
105 |
+
* Fixed woocommerce bugs
|
106 |
+
* Improved memcached flush
|
107 |
+
* Improved https force
|
108 |
+
|
109 |
= Version 5.0.8 =
|
110 |
* Better .htaccess handling when disabling and enabling Browser Cache and Gzip
|
111 |
* Improved image optimization handling
|
sg-cachepress.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* @wordpress-plugin
|
10 |
* Plugin Name: SG Optimizer
|
11 |
* Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
|
12 |
-
* Version: 5.0.
|
13 |
* Author: SiteGround
|
14 |
* Text Domain: sg-cachepress
|
15 |
* Domain Path: /languages
|
@@ -19,6 +19,8 @@
|
|
19 |
namespace SiteGround_Optimizer;
|
20 |
|
21 |
use SiteGround_Optimizer\Helper\Helper;
|
|
|
|
|
22 |
|
23 |
// If this file is called directly, abort.
|
24 |
if ( ! defined( 'WPINC' ) ) {
|
@@ -55,6 +57,9 @@ if ( ! defined( __NAMESPACE__ . '\URL' ) ) {
|
|
55 |
|
56 |
require_once( \SiteGround_Optimizer\DIR . '/vendor/autoload.php' );
|
57 |
|
|
|
|
|
|
|
58 |
// Initialize helper.
|
59 |
global $siteground_optimizer_helper;
|
60 |
|
9 |
* @wordpress-plugin
|
10 |
* Plugin Name: SG Optimizer
|
11 |
* Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
|
12 |
+
* Version: 5.0.9
|
13 |
* Author: SiteGround
|
14 |
* Text Domain: sg-cachepress
|
15 |
* Domain Path: /languages
|
19 |
namespace SiteGround_Optimizer;
|
20 |
|
21 |
use SiteGround_Optimizer\Helper\Helper;
|
22 |
+
use SiteGround_Optimizer\Activator\Activator;
|
23 |
+
use SiteGround_Optimizer\Deactivator\Deactivator;
|
24 |
|
25 |
// If this file is called directly, abort.
|
26 |
if ( ! defined( 'WPINC' ) ) {
|
57 |
|
58 |
require_once( \SiteGround_Optimizer\DIR . '/vendor/autoload.php' );
|
59 |
|
60 |
+
register_activation_hook( __FILE__, array( new Activator(), 'activate' ) );
|
61 |
+
register_deactivation_hook( __FILE__, array( new Deactivator(), 'deactivate' ) );
|
62 |
+
|
63 |
// Initialize helper.
|
64 |
global $siteground_optimizer_helper;
|
65 |
|
templates/memcached.tpl
CHANGED
@@ -1,19 +1,13 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name: Memcached
|
4 |
-
Description:
|
5 |
-
Version: 0.
|
6 |
-
Plugin URI: http://wordpress.org/extend/plugins/memcached-redux/
|
7 |
-
Author: Scott Taylor - uses code from Ryan Boren, Denis de Bernardy, Matt Martz, Mike Schroder, Mika Epstein
|
8 |
|
9 |
Install this file to wp-content/object-cache.php
|
10 |
*/
|
11 |
-
|
12 |
-
|
13 |
-
define( 'WP_CACHE_KEY_SALT', 'SG_OPTIMIZER_CACHE_KEY_SALT' );
|
14 |
-
}
|
15 |
-
|
16 |
-
if ( class_exists( 'Memcached' ) ):
|
17 |
|
18 |
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
|
19 |
global $wp_object_cache;
|
@@ -125,7 +119,12 @@ class WP_Object_Cache {
|
|
125 |
|
126 |
var $cache = array();
|
127 |
var $mc = array();
|
128 |
-
var $stats = array(
|
|
|
|
|
|
|
|
|
|
|
129 |
var $group_ops = array();
|
130 |
|
131 |
var $cache_enabled = true;
|
@@ -149,7 +148,7 @@ class WP_Object_Cache {
|
|
149 |
$result = $mc->add( $key, $data, $expire );
|
150 |
|
151 |
if ( false !== $result ) {
|
152 |
-
++$this->stats['add'];
|
153 |
$this->group_ops[$group][] = "add $id";
|
154 |
$this->cache[$key] = $data;
|
155 |
}
|
@@ -203,11 +202,11 @@ class WP_Object_Cache {
|
|
203 |
|
204 |
$result = $mc->delete( $key );
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
209 |
unset( $this->cache[$key] );
|
210 |
-
}
|
211 |
|
212 |
return $result;
|
213 |
}
|
@@ -227,9 +226,9 @@ class WP_Object_Cache {
|
|
227 |
$key = $this->key( $id, $group );
|
228 |
$mc =& $this->get_mc( $group );
|
229 |
$found = false;
|
230 |
-
|
231 |
if ( isset( $this->cache[$key] ) && ( !$force || in_array( $group, $this->no_mc_groups ) ) ) {
|
232 |
-
|
233 |
if ( is_object( $this->cache[$key] ) )
|
234 |
$value = clone $this->cache[$key];
|
235 |
else
|
@@ -239,7 +238,7 @@ class WP_Object_Cache {
|
|
239 |
} else {
|
240 |
$value = $mc->get( $key );
|
241 |
if ( empty( $value ) || ( is_integer( $value ) && -1 == $value ) ){
|
242 |
-
|
243 |
$found = $mc->getResultCode() !== Memcached::RES_NOTFOUND;
|
244 |
} else {
|
245 |
$found = true;
|
@@ -247,12 +246,8 @@ class WP_Object_Cache {
|
|
247 |
$this->cache[$key] = $value;
|
248 |
}
|
249 |
|
250 |
-
|
251 |
-
|
252 |
-
$this->group_ops[$group][] = "get $id";
|
253 |
-
} else {
|
254 |
-
++$this->stats['miss'];
|
255 |
-
}
|
256 |
|
257 |
if ( 'checkthedatabaseplease' === $value ) {
|
258 |
unset( $this->cache[$key] );
|
@@ -295,7 +290,7 @@ class WP_Object_Cache {
|
|
295 |
$return = array_merge( $return, $joined );
|
296 |
}
|
297 |
|
298 |
-
++$this->stats['get_multi'];
|
299 |
$this->group_ops[$group][] = "get_multi $id";
|
300 |
$this->cache = array_merge( $this->cache, $return );
|
301 |
return array_values( $return );
|
@@ -310,7 +305,10 @@ class WP_Object_Cache {
|
|
310 |
else
|
311 |
$prefix = $this->blog_prefix;
|
312 |
|
313 |
-
|
|
|
|
|
|
|
314 |
}
|
315 |
|
316 |
function replace( $id, $data, $group = 'default', $expire = 0 ) {
|
@@ -426,19 +424,10 @@ class WP_Object_Cache {
|
|
426 |
}
|
427 |
|
428 |
function __construct() {
|
429 |
-
|
430 |
-
$this->stats = array(
|
431 |
-
'get' => 0,
|
432 |
-
'get_multi' => 0,
|
433 |
-
'add' => 0,
|
434 |
-
'set' => 0,
|
435 |
-
'delete' => 0,
|
436 |
-
'miss' => 0,
|
437 |
-
);
|
438 |
|
439 |
$memcached_servers = array(
|
440 |
-
|
441 |
-
|
442 |
)
|
443 |
);
|
444 |
|
@@ -477,18 +466,7 @@ class WP_Object_Cache {
|
|
477 |
}
|
478 |
|
479 |
$this->cache_hits =& $this->stats['get'];
|
480 |
-
$this->cache_misses =& $this->stats['
|
481 |
}
|
482 |
}
|
483 |
-
|
484 |
-
|
485 |
-
// In 3.7+, we can handle this smoothly
|
486 |
-
if ( function_exists( 'wp_using_ext_object_cache' ) ) {
|
487 |
-
wp_using_ext_object_cache( false );
|
488 |
-
|
489 |
-
// In earlier versions, there isn't a clean bail-out method.
|
490 |
-
} else {
|
491 |
-
wp_die( 'Memcached class not available.' );
|
492 |
-
}
|
493 |
-
|
494 |
-
endif;
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Memcached
|
4 |
+
Description: Memcached Dropin for SGO
|
5 |
+
Version: 1.0.0
|
|
|
|
|
6 |
|
7 |
Install this file to wp-content/object-cache.php
|
8 |
*/
|
9 |
+
if ( class_exists( 'Memcached' ) )
|
10 |
+
{
|
|
|
|
|
|
|
|
|
11 |
|
12 |
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
|
13 |
global $wp_object_cache;
|
119 |
|
120 |
var $cache = array();
|
121 |
var $mc = array();
|
122 |
+
var $stats = array(
|
123 |
+
'add' => 0,
|
124 |
+
'delete' => 0,
|
125 |
+
'get' => 0,
|
126 |
+
'get_multi' => 0,
|
127 |
+
);
|
128 |
var $group_ops = array();
|
129 |
|
130 |
var $cache_enabled = true;
|
148 |
$result = $mc->add( $key, $data, $expire );
|
149 |
|
150 |
if ( false !== $result ) {
|
151 |
+
@ ++$this->stats['add'];
|
152 |
$this->group_ops[$group][] = "add $id";
|
153 |
$this->cache[$key] = $data;
|
154 |
}
|
202 |
|
203 |
$result = $mc->delete( $key );
|
204 |
|
205 |
+
@ ++$this->stats['delete'];
|
206 |
+
$this->group_ops[$group][] = "delete $id";
|
207 |
+
|
208 |
+
if ( false !== $result )
|
209 |
unset( $this->cache[$key] );
|
|
|
210 |
|
211 |
return $result;
|
212 |
}
|
226 |
$key = $this->key( $id, $group );
|
227 |
$mc =& $this->get_mc( $group );
|
228 |
$found = false;
|
229 |
+
|
230 |
if ( isset( $this->cache[$key] ) && ( !$force || in_array( $group, $this->no_mc_groups ) ) ) {
|
231 |
+
$found = true;
|
232 |
if ( is_object( $this->cache[$key] ) )
|
233 |
$value = clone $this->cache[$key];
|
234 |
else
|
238 |
} else {
|
239 |
$value = $mc->get( $key );
|
240 |
if ( empty( $value ) || ( is_integer( $value ) && -1 == $value ) ){
|
241 |
+
$value = false;
|
242 |
$found = $mc->getResultCode() !== Memcached::RES_NOTFOUND;
|
243 |
} else {
|
244 |
$found = true;
|
246 |
$this->cache[$key] = $value;
|
247 |
}
|
248 |
|
249 |
+
@ ++$this->stats['get'];
|
250 |
+
$this->group_ops[$group][] = "get $id";
|
|
|
|
|
|
|
|
|
251 |
|
252 |
if ( 'checkthedatabaseplease' === $value ) {
|
253 |
unset( $this->cache[$key] );
|
290 |
$return = array_merge( $return, $joined );
|
291 |
}
|
292 |
|
293 |
+
@ ++$this->stats['get_multi'];
|
294 |
$this->group_ops[$group][] = "get_multi $id";
|
295 |
$this->cache = array_merge( $this->cache, $return );
|
296 |
return array_values( $return );
|
305 |
else
|
306 |
$prefix = $this->blog_prefix;
|
307 |
|
308 |
+
if ( ! in_array( $group, $this->global_groups ) && defined( 'ICL_LANGUAGE_CODE' ) )
|
309 |
+
$prefix .= ICL_LANGUAGE_CODE . ':';
|
310 |
+
|
311 |
+
return preg_replace( '/\s+/', '', substr(md5(dirname(__FILE__)),7) . "$prefix$group:$key" );
|
312 |
}
|
313 |
|
314 |
function replace( $id, $data, $group = 'default', $expire = 0 ) {
|
424 |
}
|
425 |
|
426 |
function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
|
428 |
$memcached_servers = array(
|
429 |
+
'default' => array(
|
430 |
+
'@changedefaults@'
|
431 |
)
|
432 |
);
|
433 |
|
466 |
}
|
467 |
|
468 |
$this->cache_hits =& $this->stats['get'];
|
469 |
+
$this->cache_misses =& $this->stats['add'];
|
470 |
}
|
471 |
}
|
472 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|