A2 Optimized WP - Version 2.0.7

Version Description

*Revert use of PHP short arrays

Download this release

Release Info

Developer a2hosting
Plugin Icon 128x128 A2 Optimized WP
Version 2.0.7
Comparing to
See all releases

Code changes from version 2.0.6 to 2.0.7

Files changed (3) hide show
  1. A2_Optimized_Optimizations.php +607 -598
  2. a2-optimized.php +1 -1
  3. readme.txt +4 -1
A2_Optimized_Optimizations.php CHANGED
@@ -1,378 +1,384 @@
1
<?php
2
3
/*
4
- Author: Benjamin Cool
5
- Author URI: https://www.a2hosting.com/
6
- License: GPLv2 or Later
7
*/
8
9
- class A2_Optimized_Optimizations {
10
- private $thisclass;
11
12
- public function __construct($thisclass) {
13
- $this->thisclass = $thisclass;
14
- }
15
16
- public function get_optimizations() {
17
- $public_opts = $this->get_public_optimizations();
18
- $private_opts = $this->get_private_optimizations();
19
20
- return array_merge($public_opts, $private_opts);
21
- }
22
23
- protected function get_public_optimizations() {
24
- $thisclass = $this->thisclass;
25
26
- return [
27
- 'page_cache' => [
28
- 'slug' => 'page_cache',
29
- 'name' => 'Page Caching with W3 Total Cache',
30
- 'plugin' => 'W3 Total Cache',
31
- 'configured' => false,
32
- 'description' => 'Utilize W3 Total Cache to make the site faster by caching pages as static content. Cache: a copy of rendered dynamic pages will be saved by the server so that the next user does not need to wait for the server to generate another copy.',
33
- 'is_configured' => function (&$item) use (&$thisclass) {
34
- $w3tc = $thisclass->get_w3tc_config();
35
- if ($w3tc['pgcache.enabled']) {
36
- $item['configured'] = true;
37
- $permalink_structure = get_option('permalink_structure');
38
- $vars = [];
39
- if ($w3tc['pgcache.engine'] == 'apc') {
40
- if ($permalink_structure == '') {
41
- $vars['pgcache.engine'] = 'file';
42
- } else {
43
- $vars['pgcache.engine'] = 'file_generic';
44
- }
45
- } else {
46
- if ($permalink_structure == '' && $w3tc['pgcache.engine'] != 'file') {
47
- $vars['pgcache.engine'] = 'file';
48
- } elseif ($permalink_structure != '' && $w3tc['pgcache.engine'] == 'file') {
49
- $vars['pgcache.engine'] = 'file_generic';
50
- }
51
- }
52
53
- if (count($vars) != 0) {
54
- $thisclass->update_w3tc($vars);
55
- }
56
57
- $thisclass->set_install_status('page_cache', true);
58
- } else {
59
- $thisclass->set_install_status('page_cache', false);
60
- }
61
- },
62
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
63
- 'disable' => function () use (&$thisclass) {
64
- $thisclass->disable_w3tc_page_cache();
65
- },
66
- 'enable' => function () use (&$thisclass) {
67
- $thisclass->enable_w3tc_page_cache();
68
- }
69
- ],
70
- 'db_cache' => [
71
- 'slug' => 'db_cache',
72
- 'name' => 'DB Caching with W3 Total Cache',
73
- 'plugin' => 'W3 Total Cache',
74
- 'configured' => false,
75
- 'description' => 'Speed up the site by storing the responses of common database queries in a cache.',
76
- 'is_configured' => function (&$item) use (&$thisclass) {
77
- $w3tc = $thisclass->get_w3tc_config();
78
- if ($w3tc['dbcache.enabled']) {
79
- $vars = [];
80
- $item['configured'] = true;
81
- if (class_exists('W3_Config')) {
82
- if (class_exists('WooCommerce')) {
83
- if (array_search('_wc_session_', $w3tc['dbcache.reject.sql']) === false) {
84
- $vars['dbcache.reject.sql'] = $w3tc['dbcache.reject.sql'];
85
- $vars['dbcache.reject.sql'][] = '_wc_session_';
86
- }
87
- }
88
- }
89
- if (count($vars) != 0) {
90
- $thisclass->update_w3tc($vars);
91
- }
92
93
- $thisclass->set_install_status('db_cache', true);
94
- } else {
95
- $thisclass->set_install_status('db_cache', false);
96
- }
97
- },
98
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
99
- 'disable' => function () use (&$thisclass) {
100
- $thisclass->disable_w3tc_db_cache();
101
- },
102
- 'enable' => function () use (&$thisclass) {
103
- $thisclass->enable_w3tc_db_cache();
104
- }
105
- ],
106
107
- 'object_cache' => [
108
- 'slug' => 'object_cache',
109
- 'name' => 'Object Caching with W3 Total Cache',
110
- 'plugin' => 'W3 Total Cache',
111
- 'configured' => false,
112
- 'description' => 'Store a copy of widgets and menu bars in cache to reduce the time it takes to render pages.',
113
- 'is_configured' => function (&$item) use (&$thisclass) {
114
- $w3tc = $thisclass->get_w3tc_config();
115
- if ($w3tc['objectcache.enabled']) {
116
- $item['configured'] = true;
117
- $thisclass->set_install_status('object_cache', true);
118
- } else {
119
- $thisclass->set_install_status('object_cache', false);
120
- }
121
- },
122
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
123
- 'disable' => function () use (&$thisclass) {
124
- $thisclass->disable_w3tc_object_cache();
125
- },
126
- 'enable' => function () use (&$thisclass) {
127
- $thisclass->enable_w3tc_object_cache();
128
- }
129
- ],
130
131
- 'browser_cache' => [
132
- 'slug' => 'browser_cache',
133
- 'name' => 'Browser Caching with W3 Total Cache',
134
- 'plugin' => 'W3 Total Cache',
135
- 'configured' => false,
136
- 'description' => 'Add Rules to the web server to tell the visitor&apos;s browser to store a copy of static files to reduce the load time pages requested after the first page is loaded.',
137
- 'is_configured' => function (&$item) use (&$thisclass) {
138
- $w3tc = $thisclass->get_w3tc_config();
139
- if ($w3tc['browsercache.enabled']) {
140
- $item['configured'] = true;
141
- $thisclass->set_install_status('browser_cache', true);
142
- } else {
143
- $thisclass->set_install_status('browser_cache', false);
144
- }
145
- },
146
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
147
- 'disable' => function () use (&$thisclass) {
148
- $thisclass->disable_w3tc_browser_cache();
149
- },
150
- 'enable' => function () use (&$thisclass) {
151
- $thisclass->enable_w3tc_browser_cache();
152
- }
153
- ],
154
155
- 'minify' => [
156
- 'name' => 'Minify HTML Pages',
157
- 'slug' => 'minify',
158
- 'plugin' => 'W3 Total Cache',
159
- 'configured' => false,
160
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
161
- 'description' => 'Removes extra spaces,tabs and line breaks in the HTML to reduce the size of the files sent to the user.',
162
- 'is_configured' => function (&$item) use (&$thisclass) {
163
- $w3tc = $thisclass->get_w3tc_config();
164
- if ($w3tc['minify.enabled'] && $w3tc['minify.html.enable']) {
165
- $item['configured'] = true;
166
- $thisclass->set_install_status('minify-html', true);
167
- } else {
168
- $thisclass->set_install_status('minify-html', false);
169
- }
170
- },
171
- 'enable' => function () use (&$thisclass) {
172
- $thisclass->enable_html_minify();
173
- },
174
- 'disable' => function () use (&$thisclass) {
175
- $thisclass->disable_html_minify();
176
- }
177
- ],
178
- 'css_minify' => [
179
- 'name' => 'Minify CSS Files',
180
- 'slug' => 'css_minify',
181
- 'plugin' => 'W3 Total Cache',
182
- 'configured' => false,
183
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
184
- 'description' => 'Makes your site faster by condensing css files into a single downloadable file and by removing extra space in CSS files to make them smaller.',
185
- 'is_configured' => function (&$item) use (&$thisclass) {
186
- $w3tc = $thisclass->get_w3tc_config();
187
- if ($w3tc['minify.css.enable']) {
188
- $item['configured'] = true;
189
- $thisclass->set_install_status('minify-css', true);
190
- } else {
191
- $thisclass->set_install_status('minify-css', false);
192
- }
193
- },
194
- 'enable' => function () use (&$thisclass) {
195
- $thisclass->update_w3tc([
196
- 'minify.css.enable' => true,
197
- 'minify.enabled' => true,
198
- 'minify.auto' => 0,
199
- 'minify.engine' => 'file'
200
- ]);
201
- },
202
- 'disable' => function () use (&$thisclass) {
203
- $thisclass->update_w3tc([
204
- 'minify.css.enable' => false,
205
- 'minify.auto' => 0
206
- ]);
207
- }
208
- ],
209
- 'js_minify' => [
210
- 'name' => 'Minify JS Files',
211
- 'slug' => 'js_minify',
212
- 'plugin' => 'W3 Total Cache',
213
- 'configured' => false,
214
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
215
- 'description' => 'Makes your site faster by condensing JavaScript files into a single downloadable file and by removing extra space in JavaScript files to make them smaller.',
216
- 'is_configured' => function (&$item) use (&$thisclass) {
217
- $w3tc = $thisclass->get_w3tc_config();
218
- if ($w3tc['minify.js.enable']) {
219
- $item['configured'] = true;
220
- $thisclass->set_install_status('minify-js', true);
221
- } else {
222
- $thisclass->set_install_status('minify-js', false);
223
- }
224
- },
225
- 'enable' => function () use (&$thisclass) {
226
- $thisclass->update_w3tc([
227
- 'minify.js.enable' => true,
228
- 'minify.enabled' => true,
229
- 'minify.auto' => 0,
230
- 'minify.engine' => 'file'
231
- ]);
232
- },
233
- 'disable' => function () use (&$thisclass) {
234
- $thisclass->update_w3tc([
235
- 'minify.js.enable' => false,
236
- 'minify.auto' => 0
237
- ]);
238
- }
239
- ],
240
- 'gzip' => [
241
- 'name' => 'Gzip Compression Enabled',
242
- 'slug' => 'gzip',
243
- 'plugin' => 'W3 Total Cache',
244
- 'configured' => false,
245
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
246
- 'description' => 'Makes your site significantly faster by compressing all text files to make them smaller.',
247
- 'is_configured' => function (&$item) use (&$thisclass) {
248
- $w3tc = $thisclass->get_w3tc_config();
249
- if ($w3tc['browsercache.other.compression']) {
250
- $item['configured'] = true;
251
- $thisclass->set_install_status('gzip', true);
252
- } else {
253
- $thisclass->set_install_status('gzip', false);
254
- }
255
- },
256
- 'enable' => function () use (&$thisclass) {
257
- $thisclass->update_w3tc([
258
- 'browsercache.other.compression' => true,
259
- 'browsercache.html.compression' => true,
260
- 'browsercache.cssjs.compression' => true
261
- ]);
262
- },
263
- 'disable' => function () use (&$thisclass) {
264
- $thisclass->update_w3tc([
265
- 'browsercache.other.compression' => false,
266
- 'browsercache.html.compression' => false,
267
- 'browsercache.cssjs.compression' => false
268
- ]);
269
- }
270
- ],
271
- 'htaccess' => [
272
- 'name' => 'Deny Direct Access to Configuration Files and Comment Form',
273
- 'slug' => 'htaccess',
274
- 'plugin' => 'A2 Optimized',
275
- 'configured' => false,
276
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin',
277
- 'description' => 'Protects your configuration files by generating a Forbidden error to web users and bots when trying to access WordPress configuration files. <br> Also prevents POST requests to the site not originating from a user on the site. <br> <span class="danger" >note</span>: if you are using a plugin to allow remote posts and comments, disable this option.',
278
- 'is_configured' => function (&$item) use (&$thisclass) {
279
- $htaccess = file_get_contents(ABSPATH . '.htaccess');
280
- if (strpos($htaccess, '# BEGIN WordPress Hardening') === false) {
281
- if ($thisclass->get_deny_direct() == true) {
282
- $thisclass->set_deny_direct(false);
283
- }
284
- //make sure the basic a2-optimized rules are present
285
- $thisclass->set_install_status('htaccess-deny-direct-access', false);
286
- } else {
287
- if ($thisclass->get_deny_direct() == false) {
288
- $thisclass->set_deny_direct(true);
289
- }
290
- $item['configured'] = true;
291
- $thisclass->set_install_status('htaccess-deny-direct-access', true);
292
- }
293
- },
294
- 'enable' => function () use (&$thisclass) {
295
- $thisclass->set_deny_direct(true);
296
- $thisclass->write_htaccess();
297
- },
298
- 'disable' => function () use (&$thisclass) {
299
- $thisclass->set_deny_direct(false);
300
- $thisclass->write_htaccess();
301
- }
302
- ],
303
- 'lock' => [
304
- 'name' => 'Lock Editing of Plugins and Themes from the WP Admin',
305
- 'slug' => 'lock',
306
- 'plugin' => 'A2 Optimized',
307
- 'configured' => false,
308
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin',
309
- 'description' => 'Prevents exploits that use the built in editing capabilities of the WP Admin',
310
- 'is_configured' => function (&$item) use (&$thisclass) {
311
- $wpconfig = file_get_contents(ABSPATH . 'wp-config.php');
312
- if (strpos($wpconfig, '// BEGIN A2 CONFIG') === false) {
313
- if ($thisclass->get_lockdown() == true) {
314
- $thisclass->get_lockdown(false);
315
- }
316
- $thisclass->set_install_status('lock-editing', false);
317
- } else {
318
- if ($thisclass->get_lockdown() == false) {
319
- $thisclass->set_lockdown(true);
320
- }
321
- $item['configured'] = true;
322
- $thisclass->set_install_status('lock-editing', true);
323
- }
324
- },
325
- 'enable' => function () use (&$thisclass) {
326
- $thisclass->set_lockdown(true);
327
- $thisclass->write_wp_config();
328
- },
329
- 'disable' => function () use (&$thisclass) {
330
- $thisclass->set_lockdown(false);
331
- $thisclass->write_wp_config();
332
- }
333
- ],
334
- 'wp-login' => [
335
- 'name' => 'Login URL Change',
336
- 'slug' => 'wp-login',
337
- 'premium' => true,
338
- 'plugin' => 'Rename wp-login.php',
339
- 'configured' => false,
340
- 'kb' => 'http://www.a2hosting.com/kb/security/application-security/wordpress-security#a-namemethodRenameLoginPageaMethod-3.3A-Change-the-WordPress-login-URL',
341
- 'description' => '
342
<p>Change the URL of your login page to make it harder for bots to find it to brute force attack.</p>
343
',
344
- 'is_configured' => function () {
345
- return false;
346
- }
347
- ],
348
- 'captcha' => [
349
- 'name' => 'reCAPTCHA on comments and login',
350
- 'plugin' => 'reCAPTCHA',
351
- 'slug' => 'captcha',
352
- 'premium' => true,
353
- 'configured' => false,
354
- 'description' => 'Decreases spam and increases site security by adding a CAPTCHA to comment forms and the login screen. Without a CAPTCHA, bots will easily be able to post comments to you blog or brute force login to your admin panel.',
355
- 'is_configured' => function () {
356
- return false;
357
- }
358
- ],
359
- 'images' => [
360
- 'name' => 'Compress Images on Upload',
361
- 'plugin' => 'EWWW Image Optimizer',
362
- 'slug' => 'images',
363
- 'premium' => true,
364
- 'configured' => false,
365
- 'description' => 'Makes your site faster by compressing images to make them smaller.',
366
- 'is_configured' => function () {
367
- return false;
368
- }
369
- ],
370
- 'turbo' => [
371
- 'name' => 'Turbo Web Hosting',
372
- 'slug' => 'turbo',
373
- 'configured' => false,
374
- 'premium'=>true,
375
- 'description' => '
376
<ul>
377
<li>Turbo Web Hosting servers compile .htaccess files to make speed improvements. Any changes to .htaccess files are immediately re-compiled.</li>
378
<li>Turbo Web Hosting servers have their own PHP API that provides speed improvements over FastCGI and PHP-FPM (FastCGI Process Manager). </li>
@@ -381,16 +387,16 @@ class A2_Optimized_Optimizations {
381
<li>Turbo Web Hosting servers have a built-in caching engine for Full Page Cache and Edge Side Includes.</li>
382
</ul>
383
',
384
- 'is_configured' => function () {
385
- return false;
386
- }
387
- ],
388
- 'memcached' => [
389
- 'name' => 'Memcached Database and Object Cache',
390
- 'slug' => 'memcached',
391
- 'configured' => false,
392
- 'premium'=>true,
393
- 'description' => '
394
<ul>
395
<li>Extremely fast and powerful caching system.</li>
396
<li>Store frequently used database queries and WordPress objects in Memcached.</li>
@@ -398,44 +404,46 @@ class A2_Optimized_Optimizations {
398
<li>Take advantage of A2 Hosting&apos;s one-click memcached configuration for WordPress.</li>
399
</ul>
400
',
401
- 'is_configured' => function () {
402
- return false;
403
- }
404
- ]
405
- ];
406
- }
407
-
408
- protected function get_private_optimizations() {
409
- if (class_exists('A2_Optimized_Private_Optimizations')) {
410
- $a2opt_priv = new A2_Optimized_Private_Optimizations();
411
412
- return $a2opt_priv->get_optimizations($this->thisclass);
413
- } else {
414
- return [];
415
- }
416
- }
417
418
- public function get_advanced() {
419
- $public_opts = $this->get_public_advanced();
420
- $private_opts = $this->get_private_advanced();
421
422
- return array_merge($public_opts, $private_opts);
423
- }
424
425
- protected function get_public_advanced() {
426
- $thisclass = $this->thisclass;
427
428
- return [
429
- 'gtmetrix' => [
430
- 'slug' => 'gtmetrix',
431
- 'name' => 'GTmetrix',
432
- 'plugin' => 'GTmetrix',
433
- 'plugin_slug' => 'gtmetrix-for-wordpress',
434
- 'file' => 'gtmetrix-for-wordpress/gtmetrix-for-wordpress.php',
435
- 'configured' => false,
436
- 'partially_configured' => false,
437
- 'required_options' => ['gfw_options' => ['authorized']],
438
- 'description' => '
439
<p>
440
Plugin that actively keeps track of your WP install and sends you alerts if your site falls below certain criteria.
441
The GTMetrix plugin requires an account with <a href="http://gtmetrix.com/" >gtmetrix.com</a>
@@ -444,91 +452,91 @@ class A2_Optimized_Optimizations {
444
<b>Use this plugin only if your site is experiencing issues with slow load times.</b><br><b style="color:red">The GTMetrix plugin will slow down your site.</b>
445
</p>
446
',
447
- 'not_configured_links' => [],
448
- 'configured_links' => [
449
- 'Configure GTmetrix' => 'admin.php?page=gfw_settings',
450
- 'GTmetrix Tests' => 'admin.php?page=gfw_tests',
451
- ],
452
- 'partially_configured_links' => [
453
- 'Configure GTmetrix' => 'admin.php?page=gfw_settings',
454
- 'GTmetrix Tests' => 'admin.php?page=gfw_tests',
455
- ],
456
- 'partially_configured_message' => 'Click &quot;Configure GTmetrix&quot; to enter your GTmetrix Account Email and GTmetrix API Key.',
457
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
458
- 'is_configured' => function (&$item) use (&$thisclass) {
459
- $gfw_options = get_option('gfw_options');
460
- if (is_plugin_active($item['file']) && isset($gfw_options['authorized']) && $gfw_options['authorized'] == 1) {
461
- $item['configured'] = true;
462
- $thisclass->set_install_status('gtmetrix', true);
463
- } elseif (is_plugin_active($item['file'])) {
464
- $item['partially_configured'] = true;
465
- } else {
466
- $thisclass->set_install_status('gtmetrix', false);
467
- }
468
- },
469
- 'enable' => function ($slug) use (&$thisclass) {
470
- $item = $thisclass->get_advanced_optimizations();
471
- $item = $item[$slug];
472
- if (!isset($thisclass->plugin_list[$item['file']])) {
473
- $thisclass->install_plugin($item['plugin_slug']);
474
- }
475
- if (!is_plugin_active($item['file'])) {
476
- $thisclass->activate_plugin($item['file']);
477
- }
478
- },
479
- 'disable' => function ($slug) use (&$thisclass) {
480
- $item = $thisclass->get_advanced_optimizations();
481
- $item = $item[$slug];
482
- $thisclass->deactivate_plugin($item['file']);
483
- }
484
- ],
485
- 'P3' => [
486
- 'slug' => 'P3',
487
- 'name' => 'P3 (Plugin Performance Profiler)',
488
- 'description' => '
489
<p>See which plugins are slowing down your site.
490
This plugin creates a performance report for your site.</p>
491
<p>
492
<b>Use this plugin only if your site is experiencing issues with slow load times.</b><br><b style="color:red">The P3 plugin will slow down your site.</b>
493
</p>
494
',
495
- 'plugin' => 'P3 Profiler',
496
- 'plugin_slug' => 'p3-profiler',
497
- 'file' => 'p3-profiler/p3-profiler.php',
498
- 'configured' => false,
499
- 'configured_links' => [
500
- 'Test Performance' => 'tools.php?page=p3-profiler',
501
- ],
502
- 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/debugging-wordpress-with-p3-profiler',
503
- 'is_configured' => function (&$item) use (&$thisclass) {
504
- if (is_plugin_active($item['file'])) {
505
- $item['configured'] = true;
506
- $thisclass->set_install_status('P3', true);
507
- } else {
508
- $thisclass->set_install_status('P3', false);
509
- }
510
- },
511
- 'enable' => function ($slug) use (&$thisclass) {
512
- $item = $thisclass->get_advanced_optimizations();
513
- $item = $item[$slug];
514
- if (!isset($thisclass->plugin_list[$item['file']])) {
515
- $thisclass->install_plugin($item['plugin_slug']);
516
- }
517
- if (!is_plugin_active($item['file'])) {
518
- $thisclass->activate_plugin($item['file']);
519
- }
520
- },
521
- 'disable' => function ($slug) use (&$thisclass) {
522
- $item = $thisclass->get_advanced_optimizations();
523
- $item = $item[$slug];
524
- $thisclass->deactivate_plugin($item['file']);
525
- }
526
- ],
527
- 'cloudflare' => [
528
- 'slug' => 'cloudflare',
529
- 'name' => 'CloudFlare',
530
- 'premium'=>true,
531
- 'description' => '
532
<p>
533
CloudFlare is a free global CDN and DNS provider that can speed up and protect any site online.
534
</p>
@@ -547,130 +555,131 @@ class A2_Optimized_Optimizations {
547
Host with A2 Hosting to take advantage of one click CloudFlare configuration.
548
</div>
549
',
550
- 'configured' => false,
551
- 'is_configured' => function () {
552
- return false;
553
- },
554
- 'not_configured_links' => ['Host with A2'=>'https://www.a2hosting.com/wordpress-hosting?utm_source=A2%20Optimized&utm_medium=Referral&utm_campaign=A2%20Optimized']
555
- ]
556
- ];
557
- }
558
-
559
- protected function get_private_advanced() {
560
- if (class_exists('A2_Optimized_Private_Optimizations')) {
561
- $a2opt_priv = new A2_Optimized_Private_Optimizations();
562
-
563
- return $a2opt_priv->get_advanced($this->thisclass);
564
- } else {
565
- return [];
566
- }
567
- }
568
569
- public function get_warnings() {
570
- $public_opts = $this->get_public_warnings();
571
- $private_opts = $this->get_private_warnings();
572
573
- return array_merge($public_opts, $private_opts);
574
- }
575
576
- protected function get_public_warnings() {
577
- return [
578
- 'Bad WP Options' => [
579
- 'posts_per_page' => [
580
- 'title' => 'Recent Post Limit',
581
- 'description' => 'The number of recent posts per page is set greater than five. This could be slowing down page loads.',
582
- 'type' => 'numeric',
583
- 'threshold_type' => '>',
584
- 'threshold' => 5,
585
- 'config_url' => admin_url() . 'options-reading.php'
586
- ],
587
- 'posts_per_rss' => [
588
- 'title' => 'RSS Post Limit',
589
- 'description' => 'The number of posts from external feeds is set greater than 5. This could be slowing down page loads.',
590
- 'type' => 'numeric',
591
- 'threshold_type' => '>',
592
- 'threshold' => 5,
593
- 'config_url' => admin_url() . 'options-reading.php'
594
- ],
595
- 'show_on_front' => [
596
- 'title' => 'Recent Posts showing on home page',
597
- 'description' => 'Speed up your home page by selecting a static page to display.',
598
- 'type' => 'text',
599
- 'threshold_type' => '=',
600
- 'threshold' => 'posts',
601
- 'config_url' => admin_url() . 'options-reading.php'
602
- ],
603
- 'permalink_structure' => [
604
- 'title' => 'Permalink Structure',
605
- 'description' => 'To fully optimize page caching with "Disk Enhanced" mode:<br>you must set a permalink structure other than "Default".',
606
- 'type' => 'text',
607
- 'threshold_type' => '=',
608
- 'threshold' => '',
609
- 'config_url' => admin_url() . 'options-permalink.php'
610
- ]
611
- ],
612
- 'Advanced Warnings' => [
613
- 'themes' => [
614
- 'is_warning' => function () {
615
- $themes = wp_get_themes();
616
- switch (count($themes)) {
617
- case 1:
618
- return false;
619
- case 2:
620
- $theme = wp_get_theme();
621
- if ($theme->get('Template') != '') {
622
- return false;
623
- }
624
- }
625
626
- return true;
627
- },
628
- 'title' => 'Unused Themes',
629
- 'description' => 'One or more unused themes are installed. Unused themes should be deleted. For more information read the Wordpress.org Codex on <a target="_blank" href="http://codex.wordpress.org/WordPress_Housekeeping#Theme_Housekeeping">WordPress Housekeeping</a>',
630
- 'config_url' => admin_url() . 'themes.php'
631
- ],
632
- 'a2_hosting' => [
633
- 'title' => 'Not Hosted with A2 Hosting',
634
- 'description' => 'Get faster page load times and more optimizations when you <a href="https://www.a2hosting.com/wordpress-hosting?utm_source=A2%20Optimized&utm_medium=Referral&utm_campaign=A2%20Optimized" target="_blank">host with A2 Hosting</a>.',
635
- 'is_warning' => function () {
636
- if (is_dir('/opt/a2-optimized')) {
637
- return false;
638
- }
639
640
- return true;
641
- },
642
- 'config_url' => 'https://www.a2hosting.com/wordpress-hosting?utm_source=A2%20Optimized&utm_medium=Referral&utm_campaign=A2%20Optimized'
643
- ]
644
- ],
645
- 'Bad Plugins' => [
646
- 'wp-super-cache',
647
- 'wp-file-cache',
648
- 'wordfence',
649
- 'wp-db-backup',
650
- //'WP DB Manager',
651
- //'BackupWordPress',
652
- //'Broken Link Checker',
653
- //'MyReviewPlugin',
654
- //'LinkMan',
655
- //'Google XML Sitemaps',
656
- //'Fuzzy SEO Booster',
657
- //'Tweet Blender',
658
- //'Dynamic Related Posts',
659
- //'SEO Auto Links & Related Posts',
660
- //'Yet Another Related Posts Plugin',
661
- //'Similar Posts',
662
- //'Contextual Related Posts',
663
- ]
664
- ];
665
- }
666
667
- protected function get_private_warnings() {
668
- if (class_exists('A2_Optimized_Private_Optimizations')) {
669
- $a2opt_priv = new A2_Optimized_Private_Optimizations();
670
671
- return $a2opt_priv->get_warnings($this->thisclass);
672
- } else {
673
- return [];
674
- }
675
- }
676
}
1
<?php
2
3
/*
4
+ Author: Benjamin Cool
5
+ Author URI: https://www.a2hosting.com/
6
+ License: GPLv2 or Later
7
*/
8
9
+ class A2_Optimized_Optimizations
10
+ {
11
12
+ private $thisclass;
13
14
15
+ public function __construct($thisclass)
16
+ {
17
+ $this->thisclass = $thisclass;
18
+ }
19
20
+ public function get_optimizations()
21
+ {
22
+ $public_opts = $this->get_public_optimizations();
23
+ $private_opts = $this->get_private_optimizations();
24
+ return array_merge($public_opts, $private_opts);
25
+ }
26
27
+ protected function get_public_optimizations()
28
+ {
29
+ $thisclass = $this->thisclass;
30
31
+ return array(
32
+ 'page_cache' => array(
33
+ 'slug' => 'page_cache',
34
+ 'name' => 'Page Caching with W3 Total Cache',
35
+ 'plugin' => 'W3 Total Cache',
36
+ 'configured' => false,
37
+ 'description' => 'Utilize W3 Total Cache to make the site faster by caching pages as static content. Cache: a copy of rendered dynamic pages will be saved by the server so that the next user does not need to wait for the server to generate another copy.',
38
+ 'is_configured' => function (&$item) use (&$thisclass) {
39
+ $w3tc = $thisclass->get_w3tc_config();
40
+ if ($w3tc['pgcache.enabled']) {
41
+ $item['configured'] = true;
42
+ $permalink_structure = get_option('permalink_structure');
43
+ $vars = array();
44
+ if ($w3tc['pgcache.engine'] == 'apc') {
45
+ if ($permalink_structure == '') {
46
+ $vars['pgcache.engine'] = 'file';
47
+ } else {
48
+ $vars['pgcache.engine'] = 'file_generic';
49
+ }
50
+ } else {
51
+ if ($permalink_structure == '' && $w3tc['pgcache.engine'] != 'file') {
52
+ $vars['pgcache.engine'] = 'file';
53
+ } elseif ($permalink_structure != '' && $w3tc['pgcache.engine'] == 'file') {
54
+ $vars['pgcache.engine'] = 'file_generic';
55
+ }
56
+ }
57
58
+ if (count($vars) != 0) {
59
+ $thisclass->update_w3tc($vars);
60
+ }
61
62
+ $thisclass->set_install_status('page_cache', true);
63
+ } else {
64
+ $thisclass->set_install_status('page_cache', false);
65
+ }
66
+ },
67
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
68
+ 'disable' => function () use (&$thisclass) {
69
+ $thisclass->disable_w3tc_page_cache();
70
+ },
71
+ 'enable' => function () use (&$thisclass) {
72
+ $thisclass->enable_w3tc_page_cache();
73
+ }
74
+ ),
75
+ 'db_cache' => array(
76
+ 'slug' => 'db_cache',
77
+ 'name' => 'DB Caching with W3 Total Cache',
78
+ 'plugin' => 'W3 Total Cache',
79
+ 'configured' => false,
80
+ 'description' => 'Speed up the site by storing the responses of common database queries in a cache.',
81
+ 'is_configured' => function (&$item) use (&$thisclass) {
82
+ $w3tc = $thisclass->get_w3tc_config();
83
+ if ($w3tc['dbcache.enabled']) {
84
+ $vars = array();
85
+ $item['configured'] = true;
86
+ if (class_exists('W3_Config')) {
87
+ if (class_exists('WooCommerce')) {
88
+ if (array_search('_wc_session_', $w3tc['dbcache.reject.sql']) === false) {
89
+ $vars['dbcache.reject.sql'] = $w3tc['dbcache.reject.sql'];
90
+ $vars['dbcache.reject.sql'][] = '_wc_session_';
91
+ }
92
+ }
93
+ }
94
+ if (count($vars) != 0) {
95
+ $thisclass->update_w3tc($vars);
96
+ }
97
98
+ $thisclass->set_install_status('db_cache', true);
99
+ } else {
100
+ $thisclass->set_install_status('db_cache', false);
101
+ }
102
+ },
103
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
104
+ 'disable' => function () use (&$thisclass) {
105
+ $thisclass->disable_w3tc_db_cache();
106
+ },
107
+ 'enable' => function () use (&$thisclass) {
108
+ $thisclass->enable_w3tc_db_cache();
109
+ }
110
+ ),
111
112
+ 'object_cache' => array(
113
+ 'slug' => 'object_cache',
114
+ 'name' => 'Object Caching with W3 Total Cache',
115
+ 'plugin' => 'W3 Total Cache',
116
+ 'configured' => false,
117
+ 'description' => 'Store a copy of widgets and menu bars in cache to reduce the time it takes to render pages.',
118
+ 'is_configured' => function (&$item) use (&$thisclass) {
119
+ $w3tc = $thisclass->get_w3tc_config();
120
+ if ($w3tc['objectcache.enabled']) {
121
+ $item['configured'] = true;
122
+ $thisclass->set_install_status('object_cache', true);
123
+ } else {
124
+ $thisclass->set_install_status('object_cache', false);
125
+ }
126
+ },
127
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
128
+ 'disable' => function () use (&$thisclass) {
129
+ $thisclass->disable_w3tc_object_cache();
130
+ },
131
+ 'enable' => function () use (&$thisclass) {
132
+ $thisclass->enable_w3tc_object_cache();
133
+ }
134
+ ),
135
136
+ 'browser_cache' => array(
137
+ 'slug' => 'browser_cache',
138
+ 'name' => 'Browser Caching with W3 Total Cache',
139
+ 'plugin' => 'W3 Total Cache',
140
+ 'configured' => false,
141
+ 'description' => 'Add Rules to the web server to tell the visitor&apos;s browser to store a copy of static files to reduce the load time pages requested after the first page is loaded.',
142
+ 'is_configured' => function (&$item) use (&$thisclass) {
143
+ $w3tc = $thisclass->get_w3tc_config();
144
+ if ($w3tc['browsercache.enabled']) {
145
+ $item['configured'] = true;
146
+ $thisclass->set_install_status('browser_cache', true);
147
+ } else {
148
+ $thisclass->set_install_status('browser_cache', false);
149
+ }
150
+ },
151
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
152
+ 'disable' => function () use (&$thisclass) {
153
+ $thisclass->disable_w3tc_browser_cache();
154
+ },
155
+ 'enable' => function () use (&$thisclass) {
156
+ $thisclass->enable_w3tc_browser_cache();
157
+ }
158
+ ),
159
+
160
+ 'minify' => array(
161
+ 'name' => 'Minify HTML Pages',
162
+ 'slug' => 'minify',
163
+ 'plugin' => 'W3 Total Cache',
164
+ 'configured' => false,
165
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
166
+ 'description' => 'Removes extra spaces,tabs and line breaks in the HTML to reduce the size of the files sent to the user.',
167
+ 'is_configured' => function (&$item) use (&$thisclass) {
168
+ $w3tc = $thisclass->get_w3tc_config();
169
+ if ($w3tc['minify.enabled'] && $w3tc['minify.html.enable']) {
170
+ $item['configured'] = true;
171
+ $thisclass->set_install_status('minify-html', true);
172
+ } else {
173
+ $thisclass->set_install_status('minify-html', false);
174
+ }
175
+ },
176
+ 'enable' => function () use (&$thisclass) {
177
+ $thisclass->enable_html_minify();
178
+ },
179
+ 'disable' => function () use (&$thisclass) {
180
+ $thisclass->disable_html_minify();
181
+ }
182
+ ),
183
+ 'css_minify' => array(
184
+ 'name' => 'Minify CSS Files',
185
+ 'slug' => 'css_minify',
186
+ 'plugin' => 'W3 Total Cache',
187
+ 'configured' => false,
188
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
189
+ 'description' => 'Makes your site faster by condensing css files into a single downloadable file and by removing extra space in CSS files to make them smaller.',
190
+ 'is_configured' => function (&$item) use (&$thisclass) {
191
+ $w3tc = $thisclass->get_w3tc_config();
192
+ if ($w3tc['minify.css.enable']) {
193
+ $item['configured'] = true;
194
+ $thisclass->set_install_status('minify-css', true);
195
+ } else {
196
+ $thisclass->set_install_status('minify-css', false);
197
+ }
198
+ },
199
+ 'enable' => function () use (&$thisclass) {
200
+ $thisclass->update_w3tc(array(
201
+ 'minify.css.enable' => true,
202
+ 'minify.enabled' => true,
203
+ 'minify.auto' => 0,
204
+ 'minify.engine' => 'file'
205
+ ));
206
+ },
207
+ 'disable' => function () use (&$thisclass) {
208
+ $thisclass->update_w3tc(array(
209
+ 'minify.css.enable' => false,
210
+ 'minify.auto' => 0
211
+ ));
212
+ }
213
+ ),
214
+ 'js_minify' => array(
215
+ 'name' => 'Minify JS Files',
216
+ 'slug' => 'js_minify',
217
+ 'plugin' => 'W3 Total Cache',
218
+ 'configured' => false,
219
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
220
+ 'description' => 'Makes your site faster by condensing JavaScript files into a single downloadable file and by removing extra space in JavaScript files to make them smaller.',
221
+ 'is_configured' => function (&$item) use (&$thisclass) {
222
+ $w3tc = $thisclass->get_w3tc_config();
223
+ if ($w3tc['minify.js.enable']) {
224
+ $item['configured'] = true;
225
+ $thisclass->set_install_status('minify-js', true);
226
+ } else {
227
+ $thisclass->set_install_status('minify-js', false);
228
+ }
229
+ },
230
+ 'enable' => function () use (&$thisclass) {
231
+ $thisclass->update_w3tc(array(
232
+ 'minify.js.enable' => true,
233
+ 'minify.enabled' => true,
234
+ 'minify.auto' => 0,
235
+ 'minify.engine' => 'file'
236
+ ));
237
+ },
238
+ 'disable' => function () use (&$thisclass) {
239
+ $thisclass->update_w3tc(array(
240
+ 'minify.js.enable' => false,
241
+ 'minify.auto' => 0
242
+ ));
243
+ }
244
+
245
+ ),
246
+ 'gzip' => array(
247
+ 'name' => 'Gzip Compression Enabled',
248
+ 'slug' => 'gzip',
249
+ 'plugin' => 'W3 Total Cache',
250
+ 'configured' => false,
251
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
252
+ 'description' => 'Makes your site significantly faster by compressing all text files to make them smaller.',
253
+ 'is_configured' => function (&$item) use (&$thisclass) {
254
+ $w3tc = $thisclass->get_w3tc_config();
255
+ if ($w3tc['browsercache.other.compression']) {
256
+ $item['configured'] = true;
257
+ $thisclass->set_install_status('gzip', true);
258
+ } else {
259
+ $thisclass->set_install_status('gzip', false);
260
+ }
261
+ },
262
+ 'enable' => function () use (&$thisclass) {
263
+ $thisclass->update_w3tc(array(
264
+ 'browsercache.other.compression' => true,
265
+ 'browsercache.html.compression' => true,
266
+ 'browsercache.cssjs.compression' => true
267
+ ));
268
+ },
269
+ 'disable' => function () use (&$thisclass) {
270
+ $thisclass->update_w3tc(array(
271
+ 'browsercache.other.compression' => false,
272
+ 'browsercache.html.compression' => false,
273
+ 'browsercache.cssjs.compression' => false
274
+ ));
275
+ }
276
+ ),
277
+ 'htaccess' => array(
278
+ 'name' => 'Deny Direct Access to Configuration Files and Comment Form',
279
+ 'slug' => 'htaccess',
280
+ 'plugin' => 'A2 Optimized',
281
+ 'configured' => false,
282
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin',
283
+ 'description' => 'Protects your configuration files by generating a Forbidden error to web users and bots when trying to access WordPress configuration files. <br> Also prevents POST requests to the site not originating from a user on the site. <br> <span class="danger" >note</span>: if you are using a plugin to allow remote posts and comments, disable this option.',
284
+ 'is_configured' => function (&$item) use (&$thisclass) {
285
+ $htaccess = file_get_contents(ABSPATH . '.htaccess');
286
+ if (strpos($htaccess, "# BEGIN WordPress Hardening") === false) {
287
+ if ($thisclass->get_deny_direct() == true) {
288
+ $thisclass->set_deny_direct(false);
289
+ }
290
+ //make sure the basic a2-optimized rules are present
291
+ $thisclass->set_install_status('htaccess-deny-direct-access', false);
292
+ } else {
293
+ if ($thisclass->get_deny_direct() == false) {
294
+ $thisclass->set_deny_direct(true);
295
+ }
296
+ $item['configured'] = true;
297
+ $thisclass->set_install_status('htaccess-deny-direct-access', true);
298
+ }
299
+ },
300
+ 'enable' => function () use (&$thisclass) {
301
+ $thisclass->set_deny_direct(true);
302
+ $thisclass->write_htaccess();
303
+ },
304
+ 'disable' => function () use (&$thisclass) {
305
+ $thisclass->set_deny_direct(false);
306
+ $thisclass->write_htaccess();
307
+ }
308
+ ),
309
+ 'lock' => array(
310
+ 'name' => 'Lock Editing of Plugins and Themes from the WP Admin',
311
+ 'slug' => 'lock',
312
+ 'plugin' => 'A2 Optimized',
313
+ 'configured' => false,
314
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin',
315
+ 'description' => 'Prevents exploits that use the built in editing capabilities of the WP Admin',
316
+ 'is_configured' => function (&$item) use (&$thisclass) {
317
+ $wpconfig = file_get_contents(ABSPATH . 'wp-config.php');
318
+ if (strpos($wpconfig, "// BEGIN A2 CONFIG") === false) {
319
+ if ($thisclass->get_lockdown() == true) {
320
+ $thisclass->get_lockdown(false);
321
+ }
322
+ $thisclass->set_install_status('lock-editing', false);
323
+ } else {
324
+ if ($thisclass->get_lockdown() == false) {
325
+ $thisclass->set_lockdown(true);
326
+ }
327
+ $item['configured'] = true;
328
+ $thisclass->set_install_status('lock-editing', true);
329
+ }
330
+ },
331
+ 'enable' => function () use (&$thisclass) {
332
+ $thisclass->set_lockdown(true);
333
+ $thisclass->write_wp_config();
334
+ },
335
+ 'disable' => function () use (&$thisclass) {
336
+ $thisclass->set_lockdown(false);
337
+ $thisclass->write_wp_config();
338
+ }
339
+ ),
340
+ 'wp-login' => array(
341
+ 'name' => 'Login URL Change',
342
+ 'slug' => 'wp-login',
343
+ 'premium' => true,
344
+ 'plugin' => 'Rename wp-login.php',
345
+ 'configured' => false,
346
+ 'kb' => 'http://www.a2hosting.com/kb/security/application-security/wordpress-security#a-namemethodRenameLoginPageaMethod-3.3A-Change-the-WordPress-login-URL',
347
+ 'description' => '
348
<p>Change the URL of your login page to make it harder for bots to find it to brute force attack.</p>
349
',
350
+ 'is_configured' => function(){
351
+ return false;
352
+ }
353
+ ),
354
+ 'captcha' => array(
355
+ 'name' => 'reCAPTCHA on comments and login',
356
+ 'plugin' => 'reCAPTCHA',
357
+ 'slug' => 'captcha',
358
+ 'premium' => true,
359
+ 'configured' => false,
360
+ 'description' => 'Decreases spam and increases site security by adding a CAPTCHA to comment forms and the login screen. Without a CAPTCHA, bots will easily be able to post comments to you blog or brute force login to your admin panel.',
361
+ 'is_configured' => function (){
362
+ return false;
363
+ }
364
+ ),
365
+ 'images' => array(
366
+ 'name' => 'Compress Images on Upload',
367
+ 'plugin' => 'EWWW Image Optimizer',
368
+ 'slug' => 'images',
369
+ 'premium' => true,
370
+ 'configured' => false,
371
+ 'description' => 'Makes your site faster by compressing images to make them smaller.',
372
+ 'is_configured' => function () {
373
+ return false;
374
+ }
375
+ ),
376
+ 'turbo' => array(
377
+ 'name' => 'Turbo Web Hosting',
378
+ 'slug' => 'turbo',
379
+ 'configured' => false,
380
+ 'premium'=>true,
381
+ 'description' => '
382
<ul>
383
<li>Turbo Web Hosting servers compile .htaccess files to make speed improvements. Any changes to .htaccess files are immediately re-compiled.</li>
384
<li>Turbo Web Hosting servers have their own PHP API that provides speed improvements over FastCGI and PHP-FPM (FastCGI Process Manager). </li>
387
<li>Turbo Web Hosting servers have a built-in caching engine for Full Page Cache and Edge Side Includes.</li>
388
</ul>
389
',
390
+ 'is_configured' => function (){
391
+ return false;
392
+ }
393
+ ),
394
+ 'memcached' => array(
395
+ 'name' => 'Memcached Database and Object Cache',
396
+ 'slug' => 'memcached',
397
+ 'configured' => false,
398
+ 'premium'=>true,
399
+ 'description' => '
400
<ul>
401
<li>Extremely fast and powerful caching system.</li>
402
<li>Store frequently used database queries and WordPress objects in Memcached.</li>
404
<li>Take advantage of A2 Hosting&apos;s one-click memcached configuration for WordPress.</li>
405
</ul>
406
',
407
+ 'is_configured' => function (){
408
+ return false;
409
+ }
410
+ )
411
412
+ );
413
+ }
414
415
+ protected function get_private_optimizations()
416
+ {
417
+ if (class_exists("A2_Optimized_Private_Optimizations")) {
418
+ $a2opt_priv = new A2_Optimized_Private_Optimizations();
419
+ return $a2opt_priv->get_optimizations($this->thisclass);
420
+ } else {
421
+ return array();
422
+ }
423
+ }
424
425
+ public function get_advanced()
426
+ {
427
+ $public_opts = $this->get_public_advanced();
428
+ $private_opts = $this->get_private_advanced();
429
+ return array_merge($public_opts, $private_opts);
430
+ }
431
432
+ protected function get_public_advanced()
433
+ {
434
+ $thisclass = $this->thisclass;
435
436
+ return array(
437
+ 'gtmetrix' => array(
438
+ 'slug' => 'gtmetrix',
439
+ 'name' => 'GTmetrix',
440
+ 'plugin' => 'GTmetrix',
441
+ 'plugin_slug' => 'gtmetrix-for-wordpress',
442
+ 'file' => 'gtmetrix-for-wordpress/gtmetrix-for-wordpress.php',
443
+ 'configured' => false,
444
+ 'partially_configured' => false,
445
+ 'required_options' => array('gfw_options' => array('authorized')),
446
+ 'description' => '
447
<p>
448
Plugin that actively keeps track of your WP install and sends you alerts if your site falls below certain criteria.
449
The GTMetrix plugin requires an account with <a href="http://gtmetrix.com/" >gtmetrix.com</a>
452
<b>Use this plugin only if your site is experiencing issues with slow load times.</b><br><b style="color:red">The GTMetrix plugin will slow down your site.</b>
453
</p>
454
',
455
+ 'not_configured_links' => array(),
456
+ 'configured_links' => array(
457
+ 'Configure GTmetrix' => 'admin.php?page=gfw_settings',
458
+ 'GTmetrix Tests' => 'admin.php?page=gfw_tests',
459
+ ),
460
+ 'partially_configured_links' => array(
461
+ 'Configure GTmetrix' => 'admin.php?page=gfw_settings',
462
+ 'GTmetrix Tests' => 'admin.php?page=gfw_tests',
463
+ ),
464
+ 'partially_configured_message' => 'Click &quot;Configure GTmetrix&quot; to enter your GTmetrix Account Email and GTmetrix API Key.',
465
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
466
+ 'is_configured' => function (&$item) use (&$thisclass) {
467
+ $gfw_options = get_option('gfw_options');
468
+ if (is_plugin_active($item['file']) && isset($gfw_options['authorized']) && $gfw_options['authorized'] == 1) {
469
+ $item['configured'] = true;
470
+ $thisclass->set_install_status('gtmetrix', true);
471
+ } elseif (is_plugin_active($item['file'])) {
472
+ $item['partially_configured'] = true;
473
+ } else {
474
+ $thisclass->set_install_status('gtmetrix', false);
475
+ }
476
+ },
477
+ 'enable' => function ($slug) use (&$thisclass) {
478
+ $item = $thisclass->get_advanced_optimizations();
479
+ $item = $item[$slug];
480
+ if (!isset($thisclass->plugin_list[$item['file']])) {
481
+ $thisclass->install_plugin($item['plugin_slug']);
482
+ }
483
+ if (!is_plugin_active($item['file'])) {
484
+ $thisclass->activate_plugin($item['file']);
485
+ }
486
+ },
487
+ 'disable' => function ($slug) use (&$thisclass) {
488
+ $item = $thisclass->get_advanced_optimizations();
489
+ $item = $item[$slug];
490
+ $thisclass->deactivate_plugin($item['file']);
491
+ }
492
+ ),
493
+ 'P3' => array(
494
+ 'slug' => 'P3',
495
+ 'name' => 'P3 (Plugin Performance Profiler)',
496
+ 'description' => '
497
<p>See which plugins are slowing down your site.
498
This plugin creates a performance report for your site.</p>
499
<p>
500
<b>Use this plugin only if your site is experiencing issues with slow load times.</b><br><b style="color:red">The P3 plugin will slow down your site.</b>
501
</p>
502
',
503
+ 'plugin' => 'P3 Profiler',
504
+ 'plugin_slug' => 'p3-profiler',
505
+ 'file' => 'p3-profiler/p3-profiler.php',
506
+ 'configured' => false,
507
+ 'configured_links' => array(
508
+ 'Test Performance' => 'tools.php?page=p3-profiler',
509
+ ),
510
+ 'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/debugging-wordpress-with-p3-profiler',
511
+ 'is_configured' => function (&$item) use (&$thisclass) {
512
+ if (is_plugin_active($item['file'])) {
513
+ $item['configured'] = true;
514
+ $thisclass->set_install_status('P3', true);
515
+ } else {
516
+ $thisclass->set_install_status('P3', false);
517
+ }
518
+ },
519
+ 'enable' => function ($slug) use (&$thisclass) {
520
+ $item = $thisclass->get_advanced_optimizations();
521
+ $item = $item[$slug];
522
+ if (!isset($thisclass->plugin_list[$item['file']])) {
523
+ $thisclass->install_plugin($item['plugin_slug']);
524
+ }
525
+ if (!is_plugin_active($item['file'])) {
526
+ $thisclass->activate_plugin($item['file']);
527
+ }
528
+ },
529
+ 'disable' => function ($slug) use (&$thisclass) {
530
+ $item = $thisclass->get_advanced_optimizations();
531
+ $item = $item[$slug];
532
+ $thisclass->deactivate_plugin($item['file']);
533
+ }
534
+ ),
535
+ 'cloudflare' => array(
536
+ 'slug' => 'cloudflare',
537
+ 'name' => 'CloudFlare',
538
+ 'premium'=>true,
539
+ 'description' => '
540
<p>
541
CloudFlare is a free global CDN and DNS provider that can speed up and protect any site online.
542
</p>
555
Host with A2 Hosting to take advantage of one click CloudFlare configuration.
556
</div>
557
',
558
+ 'configured' => false,
559
+ 'is_configured' => function(){
560
+ return false;
561
+ },
562
+ 'not_configured_links' => array('Host with A2'=>'https://www.a2hosting.com/wordpress-hosting?utm_source=A2%20Optimized&utm_medium=Referral&utm_campaign=A2%20Optimized')
563
+ )
564
565
+ );
566
+ }
567
568
+ protected function get_private_advanced()
569
+ {
570
+ if (class_exists("A2_Optimized_Private_Optimizations")) {
571
+ $a2opt_priv = new A2_Optimized_Private_Optimizations();
572
+ return $a2opt_priv->get_advanced($this->thisclass);
573
+ } else {
574
+ return array();
575
+ }
576
+ }
577
578
+ public function get_warnings()
579
+ {
580
+ $public_opts = $this->get_public_warnings();
581
+ $private_opts = $this->get_private_warnings();
582
+ return array_merge($public_opts, $private_opts);
583
+ }
584
585
+ protected function get_public_warnings()
586
+ {
587
+ return array(
588
+ 'Bad WP Options' => array(
589
+ 'posts_per_page' => array(
590
+ 'title' => 'Recent Post Limit',
591
+ 'description' => 'The number of recent posts per page is set greater than five. This could be slowing down page loads.',
592
+ 'type' => 'numeric',
593
+ 'threshold_type' => '>',
594
+ 'threshold' => 5,
595
+ 'config_url' => admin_url() . 'options-reading.php'
596
+ ),
597
+ 'posts_per_rss' => array(
598
+ 'title' => 'RSS Post Limit',
599
+ 'description' => 'The number of posts from external feeds is set greater than 5. This could be slowing down page loads.',
600
+ 'type' => 'numeric',
601
+ 'threshold_type' => '>',
602
+ 'threshold' => 5,
603
+ 'config_url' => admin_url() . 'options-reading.php'
604
+ ),
605
+ 'show_on_front' => array(
606
+ 'title' => 'Recent Posts showing on home page',
607
+ 'description' => 'Speed up your home page by selecting a static page to display.',
608
+ 'type' => 'text',
609
+ 'threshold_type' => '=',
610
+ 'threshold' => 'posts',
611
+ 'config_url' => admin_url() . 'options-reading.php'
612
+ ),
613
+ 'permalink_structure' => array(
614
+ 'title' => 'Permalink Structure',
615
+ 'description' => 'To fully optimize page caching with "Disk Enhanced" mode:<br>you must set a permalink structure other than "Default".',
616
+ 'type' => 'text',
617
+ 'threshold_type' => '=',
618
+ 'threshold' => '',
619
+ 'config_url' => admin_url() . 'options-permalink.php'
620
+ )
621
+ ),
622
+ 'Advanced Warnings' => array(
623
+ 'themes' => array(
624
+ 'is_warning' => function () {
625
+ $themes = wp_get_themes();
626
+ switch (count($themes)) {
627
+ case 1:
628
+ return false;
629
+ case 2:
630
+ $theme = wp_get_theme();
631
+ if ($theme->get('Template') != '') {
632
+ return false;
633
+ }
634
+ }
635
+ return true;
636
+ },
637
+ 'title' => 'Unused Themes',
638
+ 'description' => 'One or more unused themes are installed. Unused themes should be deleted. For more information read the Wordpress.org Codex on <a target="_blank" href="http://codex.wordpress.org/WordPress_Housekeeping#Theme_Housekeeping">WordPress Housekeeping</a>',
639
+ 'config_url' => admin_url() . 'themes.php'
640
+ ),
641
+ 'a2_hosting' => array(
642
+ 'title' => 'Not Hosted with A2 Hosting',
643
+ 'description' => 'Get faster page load times and more optimizations when you <a href="https://www.a2hosting.com/wordpress-hosting?utm_source=A2%20Optimized&utm_medium=Referral&utm_campaign=A2%20Optimized" target="_blank">host with A2 Hosting</a>.',
644
+ 'is_warning' => function () {
645
+ if(is_dir("/opt/a2-optimized"))
646
+ return false;
647
+ return true;
648
+ },
649
+ 'config_url' => "https://www.a2hosting.com/wordpress-hosting?utm_source=A2%20Optimized&utm_medium=Referral&utm_campaign=A2%20Optimized"
650
+ )
651
+ ),
652
+ 'Bad Plugins' => array(
653
+ 'wp-super-cache',
654
+ 'wp-file-cache',
655
+ 'wordfence',
656
+ 'wp-db-backup',
657
+ //'WP DB Manager',
658
+ //'BackupWordPress',
659
+ //'Broken Link Checker',
660
+ //'MyReviewPlugin',
661
+ //'LinkMan',
662
+ //'Google XML Sitemaps',
663
+ //'Fuzzy SEO Booster',
664
+ //'Tweet Blender',
665
+ //'Dynamic Related Posts',
666
+ //'SEO Auto Links & Related Posts',
667
+ //'Yet Another Related Posts Plugin',
668
+ //'Similar Posts',
669
+ //'Contextual Related Posts',
670
671
+ )
672
+ );
673
+ }
674
675
+ protected function get_private_warnings()
676
+ {
677
+ if (class_exists("A2_Optimized_Private_Optimizations")) {
678
+ $a2opt_priv = new A2_Optimized_Private_Optimizations();
679
+ return $a2opt_priv->get_warnings($this->thisclass);
680
+ } else {
681
+ return array();
682
+ }
683
+ }
684
685
}
a2-optimized.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
Plugin Name: A2 Optimized WP
4
Plugin URI: https://wordpress.org/plugins/a2-optimized/
5
- Version: 2.0.6
6
Author: A2 Hosting
7
Author URI: https://www.a2hosting.com/
8
Description: A2 Optimized - WordPress Optimization Plugin
2
/*
3
Plugin Name: A2 Optimized WP
4
Plugin URI: https://wordpress.org/plugins/a2-optimized/
5
+ Version: 2.0.7
6
Author: A2 Hosting
7
Author URI: https://www.a2hosting.com/
8
Description: A2 Optimized - WordPress Optimization Plugin
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: A2BCool, a2hosting, dmatteson, sputala
3
Tags: Speed, Optimize, Secure, Fast, W3 Total Cache, W3TC, Hosting
4
Requires at least: 3.8
5
Tested up to: 4.8
6
- Stable tag: 2.0.6
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
@@ -140,6 +140,9 @@ Yes. A2 Optimized works on any host that supports WordPress. Yes. A2 Optimize
140
141
== Changelog ==
142
143
= 2.0.6 =
144
*Removed Clef and tested against WordPress 4.8
145
3
Tags: Speed, Optimize, Secure, Fast, W3 Total Cache, W3TC, Hosting
4
Requires at least: 3.8
5
Tested up to: 4.8
6
+ Stable tag: 2.0.7
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
140
141
== Changelog ==
142
143
+ = 2.0.7 =
144
+ *Revert use of PHP short arrays
145
+
146
= 2.0.6 =
147
*Removed Clef and tested against WordPress 4.8
148