Version Description
- Fixes issues with some optimizations not displaying status properly
Download this release
Release Info
Developer | a2hosting |
Plugin | A2 Optimized WP |
Version | 3.0.2 |
Comparing to | |
See all releases |
Code changes from version 3.0.1 to 3.0.2
- a2-optimized.php +3 -3
- core/A2_Optimized_Benchmark.php +0 -4
- core/A2_Optimized_Cache.php +12 -2
- core/A2_Optimized_Optimizations.php +18 -23
- readme.txt +4 -1
- requirements-config.php +1 -1
a2-optimized.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* @wordpress-plugin
|
10 |
* Plugin Name: A2 Optimized WP
|
11 |
* Plugin URI: https://wordpress.org/plugins/a2-optimized/
|
12 |
-
* Version: 3.0.
|
13 |
* Author: A2 Hosting
|
14 |
* Author URI: https://www.a2hosting.com/
|
15 |
* Description: A2 Optimized - WordPress Optimization Plugin
|
@@ -24,7 +24,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
24 |
}
|
25 |
|
26 |
define( 'A2OPT_VERSION', '3.0' );
|
27 |
-
define( 'A2OPT_FULL_VERSION', '3.0.
|
28 |
define( 'A2OPT_MIN_PHP', '5.6' );
|
29 |
define( 'A2OPT_MIN_WP', '5.1' );
|
30 |
define( 'A2OPT_FILE', __FILE__ );
|
@@ -119,4 +119,4 @@ function run_a2_optimized() {
|
|
119 |
}
|
120 |
}
|
121 |
|
122 |
-
run_a2_optimized();
|
9 |
* @wordpress-plugin
|
10 |
* Plugin Name: A2 Optimized WP
|
11 |
* Plugin URI: https://wordpress.org/plugins/a2-optimized/
|
12 |
+
* Version: 3.0.2
|
13 |
* Author: A2 Hosting
|
14 |
* Author URI: https://www.a2hosting.com/
|
15 |
* Description: A2 Optimized - WordPress Optimization Plugin
|
24 |
}
|
25 |
|
26 |
define( 'A2OPT_VERSION', '3.0' );
|
27 |
+
define( 'A2OPT_FULL_VERSION', '3.0.2' );
|
28 |
define( 'A2OPT_MIN_PHP', '5.6' );
|
29 |
define( 'A2OPT_MIN_WP', '5.1' );
|
30 |
define( 'A2OPT_FILE', __FILE__ );
|
119 |
}
|
120 |
}
|
121 |
|
122 |
+
run_a2_optimized();
|
core/A2_Optimized_Benchmark.php
CHANGED
@@ -38,10 +38,6 @@ class A2_Optimized_Benchmark {
|
|
38 |
*/
|
39 |
|
40 |
public function run_hosting_test_suite($result_desc = null) {
|
41 |
-
if (!current_user_can('manage_options') && !defined( 'WP_CLI' )) {
|
42 |
-
wp_die(__('There was a problem loading this page, you may not have the necessary permissions, or may need to <a href="' . get_option('siteurl') . '/wp-login.php">' . __('login') . '</a>.'));
|
43 |
-
}
|
44 |
-
|
45 |
$existing_results = [];
|
46 |
|
47 |
try{
|
38 |
*/
|
39 |
|
40 |
public function run_hosting_test_suite($result_desc = null) {
|
|
|
|
|
|
|
|
|
41 |
$existing_results = [];
|
42 |
|
43 |
try{
|
core/A2_Optimized_Cache.php
CHANGED
@@ -1000,8 +1000,8 @@ final class A2_Optimized_Cache {
|
|
1000 |
return;
|
1001 |
}
|
1002 |
|
1003 |
-
// check advanced-cache.php drop-in
|
1004 |
-
if ( ! file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) && is_plugin_active('litespeed-cache/litespeed-cache.php')) {
|
1005 |
echo sprintf(
|
1006 |
'<div class="notice notice-warning"><p>%s</p></div>',
|
1007 |
sprintf(
|
@@ -1015,6 +1015,16 @@ final class A2_Optimized_Cache {
|
|
1015 |
);
|
1016 |
}
|
1017 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1018 |
// check permalink structure
|
1019 |
if ( A2_Optimized_Cache_Engine::$settings['permalink_structure'] === 'plain' && current_user_can( 'manage_options' ) ) {
|
1020 |
echo sprintf(
|
1000 |
return;
|
1001 |
}
|
1002 |
|
1003 |
+
// check advanced-cache.php drop-in exists
|
1004 |
+
if ( ! file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) && !is_plugin_active('litespeed-cache/litespeed-cache.php') && get_option('a2_cache_enabled') == 1) {
|
1005 |
echo sprintf(
|
1006 |
'<div class="notice notice-warning"><p>%s</p></div>',
|
1007 |
sprintf(
|
1015 |
);
|
1016 |
}
|
1017 |
|
1018 |
+
// check advanced-cache.php drop-in is ours
|
1019 |
+
if (file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) && !is_plugin_active('litespeed-cache/litespeed-cache.php') && get_option('a2_cache_enabled') == 1) {
|
1020 |
+
$existing_hash = md5(WP_CONTENT_DIR . '/advanced-cache.php');
|
1021 |
+
$plugin_hash = md5(A2OPT_DIR . '/advanced-cache.php');
|
1022 |
+
if($plugin_hash != $existing_hash){
|
1023 |
+
@unlink( WP_CONTENT_DIR . '/advanced-cache.php' );
|
1024 |
+
A2_Optimized_Cache_Disk::setup();
|
1025 |
+
}
|
1026 |
+
}
|
1027 |
+
|
1028 |
// check permalink structure
|
1029 |
if ( A2_Optimized_Cache_Engine::$settings['permalink_structure'] === 'plain' && current_user_can( 'manage_options' ) ) {
|
1030 |
echo sprintf(
|
core/A2_Optimized_Optimizations.php
CHANGED
@@ -1239,6 +1239,7 @@ class A2_Optimized_Optimizations {
|
|
1239 |
} else {
|
1240 |
update_option('a2_optimized_lockdown', '1');
|
1241 |
}
|
|
|
1242 |
}
|
1243 |
|
1244 |
public function set_nomods($lockdown = true) {
|
@@ -1247,14 +1248,16 @@ class A2_Optimized_Optimizations {
|
|
1247 |
} else {
|
1248 |
update_option('a2_optimized_nomods', '1');
|
1249 |
}
|
|
|
1250 |
}
|
1251 |
|
1252 |
public function set_deny_direct($deny = true) {
|
1253 |
if ($deny == false) {
|
1254 |
-
|
1255 |
} else {
|
1256 |
update_option('a2_optimized_deny_direct', '1');
|
1257 |
}
|
|
|
1258 |
}
|
1259 |
|
1260 |
public function write_htaccess() {
|
@@ -1274,11 +1277,13 @@ class A2_Optimized_Optimizations {
|
|
1274 |
$home_path = "/{$home_path[1]}/";
|
1275 |
}
|
1276 |
|
|
|
1277 |
$a2hardening = '';
|
1278 |
|
1279 |
-
|
1280 |
-
$a2hardening = <<<APACHE
|
1281 |
|
|
|
|
|
1282 |
# BEGIN WordPress Hardening
|
1283 |
<FilesMatch "^.*(error_log|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
|
1284 |
Order deny,allow
|
@@ -1301,17 +1306,15 @@ Deny from all
|
|
1301 |
RewriteRule (.*) - [F,L]
|
1302 |
</IfModule>
|
1303 |
# END WordPress Hardening
|
|
|
1304 |
APACHE;
|
1305 |
}
|
1306 |
|
1307 |
-
$htaccess = file_get_contents(ABSPATH . '.htaccess');
|
1308 |
-
|
1309 |
$pattern = "/[\r\n]*# BEGIN WordPress Hardening.*# END WordPress Hardening[\r\n]*/msiU";
|
1310 |
$htaccess = preg_replace($pattern, '', $htaccess);
|
1311 |
|
1312 |
$htaccess = <<<HTACCESS
|
1313 |
-
$a2hardening
|
1314 |
-
$htaccess
|
1315 |
HTACCESS;
|
1316 |
|
1317 |
//Write the rules to .htaccess
|
@@ -1418,7 +1421,7 @@ PHP;
|
|
1418 |
}
|
1419 |
|
1420 |
/* Block this xmlrpc request unless other criteria are met */
|
1421 |
-
|
1422 |
if ($this->client_is_automattic()) {
|
1423 |
return;
|
1424 |
}
|
@@ -1437,12 +1440,12 @@ PHP;
|
|
1437 |
}
|
1438 |
|
1439 |
/* Stop advertising we accept certain requests */
|
1440 |
-
public static function remove_xmlrpc_methods() {
|
1441 |
-
if (
|
1442 |
return $xml_rpc_methods;
|
1443 |
}
|
1444 |
|
1445 |
-
if (
|
1446 |
return $xml_rpc_methods;
|
1447 |
}
|
1448 |
|
@@ -1452,7 +1455,7 @@ PHP;
|
|
1452 |
return $xml_rpc_methods;
|
1453 |
}
|
1454 |
|
1455 |
-
public function clientip_whitelisted() {
|
1456 |
// For future consideration
|
1457 |
return false;
|
1458 |
}
|
@@ -1461,17 +1464,9 @@ PHP;
|
|
1461 |
Checks if IP making request if from Automattic
|
1462 |
https://jetpack.com/support/hosting-faq/
|
1463 |
*/
|
1464 |
-
public function client_is_automattic() {
|
1465 |
-
//check for jetpack / akismet / vaultpress
|
1466 |
-
if (
|
1467 |
-
!is_plugin_active('jetpack/jetpack.php')
|
1468 |
-
&& !is_plugin_active('akismet/akismet.php')
|
1469 |
-
&& !is_plugin_active('vaultpress/vaultpress.php')) {
|
1470 |
-
return false;
|
1471 |
-
}
|
1472 |
-
|
1473 |
$ip_address = $_SERVER['REMOTE_ADDR'];
|
1474 |
-
if (
|
1475 |
$ip_address,
|
1476 |
[
|
1477 |
'122.248.245.244', // Jetpack
|
@@ -1491,7 +1486,7 @@ PHP;
|
|
1491 |
}
|
1492 |
|
1493 |
/* Use ip2long to do comparisons */
|
1494 |
-
public function is_ip_in_range($ip_address, $range_array) {
|
1495 |
$ip_long = ip2long($ip_address);
|
1496 |
foreach ($range_array as $item) {
|
1497 |
if (is_array($item)) {
|
1239 |
} else {
|
1240 |
update_option('a2_optimized_lockdown', '1');
|
1241 |
}
|
1242 |
+
$this->write_htaccess();
|
1243 |
}
|
1244 |
|
1245 |
public function set_nomods($lockdown = true) {
|
1248 |
} else {
|
1249 |
update_option('a2_optimized_nomods', '1');
|
1250 |
}
|
1251 |
+
$this->write_htaccess();
|
1252 |
}
|
1253 |
|
1254 |
public function set_deny_direct($deny = true) {
|
1255 |
if ($deny == false) {
|
1256 |
+
update_option('a2_optimized_deny_direct', '0');
|
1257 |
} else {
|
1258 |
update_option('a2_optimized_deny_direct', '1');
|
1259 |
}
|
1260 |
+
$this->write_htaccess();
|
1261 |
}
|
1262 |
|
1263 |
public function write_htaccess() {
|
1277 |
$home_path = "/{$home_path[1]}/";
|
1278 |
}
|
1279 |
|
1280 |
+
$htaccess = file_get_contents(ABSPATH . '.htaccess');
|
1281 |
$a2hardening = '';
|
1282 |
|
1283 |
+
$deny_direct = get_option('a2_optimized_deny_direct');
|
|
|
1284 |
|
1285 |
+
if ($deny_direct == '1' && strpos($htaccess, '# BEGIN WordPress Hardening') == false ) {
|
1286 |
+
$a2hardening = <<<APACHE
|
1287 |
# BEGIN WordPress Hardening
|
1288 |
<FilesMatch "^.*(error_log|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
|
1289 |
Order deny,allow
|
1306 |
RewriteRule (.*) - [F,L]
|
1307 |
</IfModule>
|
1308 |
# END WordPress Hardening
|
1309 |
+
|
1310 |
APACHE;
|
1311 |
}
|
1312 |
|
|
|
|
|
1313 |
$pattern = "/[\r\n]*# BEGIN WordPress Hardening.*# END WordPress Hardening[\r\n]*/msiU";
|
1314 |
$htaccess = preg_replace($pattern, '', $htaccess);
|
1315 |
|
1316 |
$htaccess = <<<HTACCESS
|
1317 |
+
$a2hardening $htaccess
|
|
|
1318 |
HTACCESS;
|
1319 |
|
1320 |
//Write the rules to .htaccess
|
1421 |
}
|
1422 |
|
1423 |
/* Block this xmlrpc request unless other criteria are met */
|
1424 |
+
public function block_xmlrpc_request() {
|
1425 |
if ($this->client_is_automattic()) {
|
1426 |
return;
|
1427 |
}
|
1440 |
}
|
1441 |
|
1442 |
/* Stop advertising we accept certain requests */
|
1443 |
+
public static function remove_xmlrpc_methods($xml_rpc_methods) {
|
1444 |
+
if (self::client_is_automattic()) {
|
1445 |
return $xml_rpc_methods;
|
1446 |
}
|
1447 |
|
1448 |
+
if (self::clientip_whitelisted()) {
|
1449 |
return $xml_rpc_methods;
|
1450 |
}
|
1451 |
|
1455 |
return $xml_rpc_methods;
|
1456 |
}
|
1457 |
|
1458 |
+
public static function clientip_whitelisted() {
|
1459 |
// For future consideration
|
1460 |
return false;
|
1461 |
}
|
1464 |
Checks if IP making request if from Automattic
|
1465 |
https://jetpack.com/support/hosting-faq/
|
1466 |
*/
|
1467 |
+
public static function client_is_automattic() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1468 |
$ip_address = $_SERVER['REMOTE_ADDR'];
|
1469 |
+
if (self::is_ip_in_range(
|
1470 |
$ip_address,
|
1471 |
[
|
1472 |
'122.248.245.244', // Jetpack
|
1486 |
}
|
1487 |
|
1488 |
/* Use ip2long to do comparisons */
|
1489 |
+
public static function is_ip_in_range($ip_address, $range_array) {
|
1490 |
$ip_long = ip2long($ip_address);
|
1491 |
foreach ($range_array as $item) {
|
1492 |
if (is_array($item)) {
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: a2hosting, supersoju
|
|
3 |
Tags: a2 hosting, cache, caching, speed, fast, optimize, site performance, image optimization, image compression, site security, seo, gzip compression, minify code, code minification
|
4 |
Requires at least: 5.1
|
5 |
Tested up to: 6.1
|
6 |
-
Stable tag: 3.0.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -150,6 +150,9 @@ Yes. A2 Optimized works on any host that supports WordPress; however, A2 Hostin
|
|
150 |
|
151 |
== Changelog ==
|
152 |
|
|
|
|
|
|
|
153 |
= 3.0.0 =
|
154 |
* Fresh new UI
|
155 |
* Front-end and Back-end benchmarks
|
3 |
Tags: a2 hosting, cache, caching, speed, fast, optimize, site performance, image optimization, image compression, site security, seo, gzip compression, minify code, code minification
|
4 |
Requires at least: 5.1
|
5 |
Tested up to: 6.1
|
6 |
+
Stable tag: 3.0.2
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
150 |
|
151 |
== Changelog ==
|
152 |
|
153 |
+
= 3.0.2 =
|
154 |
+
* Fixes issues with some optimizations not displaying status properly
|
155 |
+
|
156 |
= 3.0.0 =
|
157 |
* Fresh new UI
|
158 |
* Front-end and Back-end benchmarks
|
requirements-config.php
CHANGED
@@ -11,7 +11,7 @@ return [
|
|
11 |
|
12 |
'min_wp_version' => '5.1', // Minimum WordPress Version.
|
13 |
|
14 |
-
'is_multisite_compatible' =>
|
15 |
|
16 |
'required_plugins' => [ // Plugins on which our plugin is dependent on.
|
17 |
|
11 |
|
12 |
'min_wp_version' => '5.1', // Minimum WordPress Version.
|
13 |
|
14 |
+
'is_multisite_compatible' => true, // True if our plugin is Multisite Compatible.
|
15 |
|
16 |
'required_plugins' => [ // Plugins on which our plugin is dependent on.
|
17 |
|