Version Description
Download this release
Release Info
Developer | sstoqnov |
Plugin | SG Optimizer |
Version | 5.1.3 |
Comparing to | |
See all releases |
Code changes from version 5.1.2 to 5.1.3
- assets/css/lazy-load.css +13 -0
- assets/js/index.html +10 -0
- core/Cli/Cli_Memcache.php +1 -1
- core/Cli/Cli_Status.php +1 -1
- core/Combinator/Combinator.php +10 -12
- core/Front_End_Optimization/Front_End_Optimization.php +1 -1
- core/Images_Optimizer/Images_Optimizer.php +15 -0
- core/Rest/Rest_Helper.php +1 -1
- readme.txt +6 -1
- sg-cachepress.php +2 -2
assets/css/lazy-load.css
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.lazy-hidden {
|
2 |
+
background: none;
|
3 |
+
opacity: 0;
|
4 |
+
}
|
5 |
+
|
6 |
+
.lazy-loaded {
|
7 |
+
-webkit-transition: opacity 0.8s;
|
8 |
+
-moz-transition: opacity 0.8s;
|
9 |
+
-ms-transition: opacity 0.8s;
|
10 |
+
-o-transition: opacity 0.8s;
|
11 |
+
transition: opacity 0.8s;
|
12 |
+
opacity: 1;
|
13 |
+
}
|
assets/js/index.html
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>Title</title>
|
5 |
+
</head>
|
6 |
+
<body>
|
7 |
+
<div id="sg-optimizer-app"></div>
|
8 |
+
<script type="text/javascript" src="bundle.js"></script>
|
9 |
+
</body>
|
10 |
+
</html>
|
core/Cli/Cli_Memcache.php
CHANGED
@@ -39,7 +39,7 @@ class Cli_Memcache {
|
|
39 |
$port = $memcache->get_memcached_port();
|
40 |
|
41 |
if ( empty( $port ) ) {
|
42 |
-
return \WP_CLI::error( 'SG
|
43 |
}
|
44 |
|
45 |
// First enable the option.
|
39 |
$port = $memcache->get_memcached_port();
|
40 |
|
41 |
if ( empty( $port ) ) {
|
42 |
+
return \WP_CLI::error( 'SG Optimizer was unable to connect to the Memcached server and it was disabled. Please, check your cPanel and turn it on if disabled.' );
|
43 |
}
|
44 |
|
45 |
// First enable the option.
|
core/Cli/Cli_Status.php
CHANGED
@@ -20,7 +20,7 @@ use SiteGround_Optimizer\Htaccess\Htaccess;
|
|
20 |
*/
|
21 |
class Cli_Status {
|
22 |
/**
|
23 |
-
*
|
24 |
*
|
25 |
* ## OPTIONS
|
26 |
*
|
20 |
*/
|
21 |
class Cli_Status {
|
22 |
/**
|
23 |
+
* Return the current status of specific optimization
|
24 |
*
|
25 |
* ## OPTIONS
|
26 |
*
|
core/Combinator/Combinator.php
CHANGED
@@ -43,6 +43,7 @@ class Combinator {
|
|
43 |
private $combined_styles_exclude_list = array(
|
44 |
'siteground-optimizer-combined-styles-header',
|
45 |
'siteground-optimizer-combined-styles-footer',
|
|
|
46 |
);
|
47 |
|
48 |
/**
|
@@ -65,11 +66,12 @@ class Combinator {
|
|
65 |
|
66 |
// Minify the css files.
|
67 |
add_action( 'wp_print_styles', array( $this, 'pre_combine_header_styles' ), 10 );
|
|
|
68 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_header_combined_styles' ) );
|
|
|
69 |
// We may combine footer styles in upcoming versions.
|
70 |
// add_action( 'wp_print_footer_scripts', array( $this, 'combine_styles' ), 10 );
|
71 |
// add_action( 'get_footer', array( $this, 'enqueue_footer_combined_styles' ) );
|
72 |
-
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -146,7 +148,8 @@ class Combinator {
|
|
146 |
in_array( $handle, $excluded_styles ) || // If the style is excluded from combination.
|
147 |
false === $wp_styles->registered[ $handle ]->src || // If the source is empty.
|
148 |
@strpos( Helper::get_home_url(), parse_url( $wp_styles->registered[ $handle ]->src, PHP_URL_HOST ) ) === false || // Skip all external sources.
|
149 |
-
pathinfo( $wp_styles->registered[ $handle ]->src, PATHINFO_EXTENSION ) === 'php' // If it's dynamically generated css.
|
|
|
150 |
) {
|
151 |
continue;
|
152 |
}
|
@@ -220,22 +223,18 @@ class Combinator {
|
|
220 |
|
221 |
$replacements = array();
|
222 |
|
223 |
-
|
224 |
preg_match_all( $regex, $content, $matches );
|
225 |
|
226 |
if ( ! empty( $matches ) ) {
|
227 |
foreach ( $matches[1] as $index => $match ) {
|
|
|
228 |
|
229 |
// Bail if the url is valid.
|
230 |
-
if (
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
$full_url = $dir . trim( $match, " \t\n\r\0\x0B\"'" );
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
$replacements[ $matches[0][ $index ] ] = $replacement;
|
239 |
}
|
240 |
}
|
241 |
|
@@ -282,6 +281,5 @@ class Combinator {
|
|
282 |
);
|
283 |
|
284 |
return $data;
|
285 |
-
|
286 |
}
|
287 |
}
|
43 |
private $combined_styles_exclude_list = array(
|
44 |
'siteground-optimizer-combined-styles-header',
|
45 |
'siteground-optimizer-combined-styles-footer',
|
46 |
+
'elementor-frontend', // Excluded in 5.1.3.
|
47 |
);
|
48 |
|
49 |
/**
|
66 |
|
67 |
// Minify the css files.
|
68 |
add_action( 'wp_print_styles', array( $this, 'pre_combine_header_styles' ), 10 );
|
69 |
+
add_action( 'print_embed_styles', array( $this, 'pre_combine_header_styles' ), 10 );
|
70 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_header_combined_styles' ) );
|
71 |
+
add_action( 'enqueue_embed_scripts', array( $this, 'enqueue_header_combined_styles' ) );
|
72 |
// We may combine footer styles in upcoming versions.
|
73 |
// add_action( 'wp_print_footer_scripts', array( $this, 'combine_styles' ), 10 );
|
74 |
// add_action( 'get_footer', array( $this, 'enqueue_footer_combined_styles' ) );
|
|
|
75 |
}
|
76 |
|
77 |
/**
|
148 |
in_array( $handle, $excluded_styles ) || // If the style is excluded from combination.
|
149 |
false === $wp_styles->registered[ $handle ]->src || // If the source is empty.
|
150 |
@strpos( Helper::get_home_url(), parse_url( $wp_styles->registered[ $handle ]->src, PHP_URL_HOST ) ) === false || // Skip all external sources.
|
151 |
+
pathinfo( $wp_styles->registered[ $handle ]->src, PATHINFO_EXTENSION ) === 'php' || // If it's dynamically generated css.
|
152 |
+
is_int( strpos( $handle, 'elementor-post-' ) ) // Exclude all elementor styles.
|
153 |
) {
|
154 |
continue;
|
155 |
}
|
223 |
|
224 |
$replacements = array();
|
225 |
|
|
|
226 |
preg_match_all( $regex, $content, $matches );
|
227 |
|
228 |
if ( ! empty( $matches ) ) {
|
229 |
foreach ( $matches[1] as $index => $match ) {
|
230 |
+
$match = trim( $match, " \t\n\r\0\x0B\"'" );
|
231 |
|
232 |
// Bail if the url is valid.
|
233 |
+
if ( false == preg_match( '~(http(?:s)?:)?\/\/(?:[\w-]+\.)*([\w-]{1,63})(?:\.(?:\w{3}|\w{2}))(?:$|\/)~', $match ) ) {
|
234 |
+
$replacement = str_replace( $match, $dir . $match, $matches[0][ $index ] );
|
|
|
|
|
|
|
235 |
|
236 |
+
$replacements[ $matches[0][ $index ] ] = $replacement;
|
237 |
+
}
|
|
|
238 |
}
|
239 |
}
|
240 |
|
281 |
);
|
282 |
|
283 |
return $data;
|
|
|
284 |
}
|
285 |
}
|
core/Front_End_Optimization/Front_End_Optimization.php
CHANGED
@@ -69,7 +69,6 @@ class Front_End_Optimization {
|
|
69 |
new Images_Optimizer();
|
70 |
}
|
71 |
|
72 |
-
|
73 |
if (
|
74 |
is_admin() ||
|
75 |
$this->check_for_builders()
|
@@ -292,6 +291,7 @@ class Front_End_Optimization {
|
|
292 |
'version',
|
293 |
'v',
|
294 |
'generated',
|
|
|
295 |
),
|
296 |
$src
|
297 |
);
|
69 |
new Images_Optimizer();
|
70 |
}
|
71 |
|
|
|
72 |
if (
|
73 |
is_admin() ||
|
74 |
$this->check_for_builders()
|
291 |
'version',
|
292 |
'v',
|
293 |
'generated',
|
294 |
+
'timestamp',
|
295 |
),
|
296 |
$src
|
297 |
);
|
core/Images_Optimizer/Images_Optimizer.php
CHANGED
@@ -17,6 +17,15 @@ class Images_Optimizer {
|
|
17 |
*/
|
18 |
const BATCH_LIMIT = 200;
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
/**
|
21 |
* The constructor.
|
22 |
*
|
@@ -265,6 +274,12 @@ class Images_Optimizer {
|
|
265 |
break;
|
266 |
|
267 |
case IMAGETYPE_PNG:
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
$placeholder = 'optipng -o2 %s 2>&1';
|
269 |
break;
|
270 |
|
17 |
*/
|
18 |
const BATCH_LIMIT = 200;
|
19 |
|
20 |
+
/**
|
21 |
+
* The png image size limit. Bigger images won't be optimized.
|
22 |
+
*
|
23 |
+
* @since 5.0.0
|
24 |
+
*
|
25 |
+
* @var int The png image size limit.
|
26 |
+
*/
|
27 |
+
const PNGS_SIZE_LIMIT = 500000;
|
28 |
+
|
29 |
/**
|
30 |
* The constructor.
|
31 |
*
|
274 |
break;
|
275 |
|
276 |
case IMAGETYPE_PNG:
|
277 |
+
// Bail if the image is bigger than 500k.
|
278 |
+
// PNG usage is not recommended and images bigger than 500kb
|
279 |
+
// hit the limits.
|
280 |
+
if ( filesize( $filepath ) > self::PNGS_SIZE_LIMIT ) {
|
281 |
+
return true;
|
282 |
+
}
|
283 |
$placeholder = 'optipng -o2 %s 2>&1';
|
284 |
break;
|
285 |
|
core/Rest/Rest_Helper.php
CHANGED
@@ -204,7 +204,7 @@ class Rest_Helper {
|
|
204 |
if ( empty( $port ) ) {
|
205 |
wp_send_json_error(
|
206 |
array(
|
207 |
-
'message' => __( 'SG
|
208 |
)
|
209 |
);
|
210 |
}
|
204 |
if ( empty( $port ) ) {
|
205 |
wp_send_json_error(
|
206 |
array(
|
207 |
+
'message' => __( 'SG Optimizer was unable to connect to the Memcached server and it was disabled. Please, check your cPanel and turn it on if disabled.', 'sg-cachepress' ),
|
208 |
)
|
209 |
);
|
210 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,6 @@ Tags: nginx, caching, speed, memcache, memcached, performance, siteground, nginx
|
|
4 |
Requires at least: 4.7
|
5 |
Requires PHP: 5.5
|
6 |
Tested up to: 5.2
|
7 |
-
Stable tag: 1.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -170,6 +169,12 @@ Our plugin uses a cookie in order to function properly. It does not store person
|
|
170 |
|
171 |
== Changelog ==
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
= Version 5.1.2 =
|
174 |
* Added support for Recommended by SiteGround PHP Version
|
175 |
* Improved LazyLoad Support for WooCommerce sites
|
4 |
Requires at least: 4.7
|
5 |
Requires PHP: 5.5
|
6 |
Tested up to: 5.2
|
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
169 |
|
170 |
== Changelog ==
|
171 |
|
172 |
+
= Version 5.1.3 =
|
173 |
+
* Improved Elementor support
|
174 |
+
* Improved CSS optimization for inclusions without protocol
|
175 |
+
* Excluded large PNGs from optimizations
|
176 |
+
* Added better WP-CLI command documentation
|
177 |
+
|
178 |
= Version 5.1.2 =
|
179 |
* Added support for Recommended by SiteGround PHP Version
|
180 |
* Improved LazyLoad Support for WooCommerce sites
|
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.1.
|
13 |
* Author: SiteGround
|
14 |
* Text Domain: sg-cachepress
|
15 |
* Domain Path: /languages
|
@@ -29,7 +29,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
29 |
|
30 |
// Define version constant.
|
31 |
if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
|
32 |
-
define( __NAMESPACE__ . '\VERSION', '5.1.
|
33 |
}
|
34 |
|
35 |
// Define slug constant.
|
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.1.3
|
13 |
* Author: SiteGround
|
14 |
* Text Domain: sg-cachepress
|
15 |
* Domain Path: /languages
|
29 |
|
30 |
// Define version constant.
|
31 |
if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
|
32 |
+
define( __NAMESPACE__ . '\VERSION', '5.1.3' );
|
33 |
}
|
34 |
|
35 |
// Define slug constant.
|