thisclass = $thisclass;
}
public function get_optimizations()
{
$public_opts = $this->get_public_optimizations();
$private_opts = $this->get_private_optimizations();
return array_merge($public_opts, $private_opts);
}
protected function get_public_optimizations()
{
$thisclass = $this->thisclass;
return array(
'page_cache' => array(
'slug' => 'page_cache',
'name' => 'Page Caching with W3 Total Cache',
'plugin' => 'W3 Total Cache',
'configured' => false,
'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.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['pgcache.enabled']) {
$item['configured'] = true;
$permalink_structure = get_option('permalink_structure');
$vars = array();
if ($w3tc['pgcache.engine'] == 'apc') {
if ($permalink_structure == '') {
$vars['pgcache.engine'] = 'file';
} else {
$vars['pgcache.engine'] = 'file_generic';
}
} else {
if ($permalink_structure == '' && $w3tc['pgcache.engine'] != 'file') {
$vars['pgcache.engine'] = 'file';
} elseif ($permalink_structure != '' && $w3tc['pgcache.engine'] == 'file') {
$vars['pgcache.engine'] = 'file_generic';
}
}
if (count($vars) != 0) {
$thisclass->update_w3tc($vars);
}
$thisclass->set_install_status('page_cache', true);
} else {
$thisclass->set_install_status('page_cache', false);
}
},
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'disable' => function () use (&$thisclass) {
$thisclass->disable_w3tc_page_cache();
},
'enable' => function () use (&$thisclass) {
$thisclass->enable_w3tc_page_cache();
}
),
'db_cache' => array(
'slug' => 'db_cache',
'name' => 'DB Caching with W3 Total Cache',
'plugin' => 'W3 Total Cache',
'configured' => false,
'description' => 'Speed up the site by storing the responses of common database queries in a cache.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['dbcache.enabled']) {
$vars = array();
$item['configured'] = true;
if (class_exists('W3_Config')) {
if (class_exists('WooCommerce')) {
if (array_search('_wc_session_', $w3tc['dbcache.reject.sql']) === false) {
$vars['dbcache.reject.sql'] = $w3tc['dbcache.reject.sql'];
$vars['dbcache.reject.sql'][] = '_wc_session_';
}
}
}
if (count($vars) != 0) {
$thisclass->update_w3tc($vars);
}
$thisclass->set_install_status('db_cache', true);
} else {
$thisclass->set_install_status('db_cache', false);
}
},
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'disable' => function () use (&$thisclass) {
$thisclass->disable_w3tc_db_cache();
},
'enable' => function () use (&$thisclass) {
$thisclass->enable_w3tc_db_cache();
}
),
'object_cache' => array(
'slug' => 'object_cache',
'name' => 'Object Caching with W3 Total Cache',
'plugin' => 'W3 Total Cache',
'configured' => false,
'description' => 'Store a copy of widgets and menu bars in cache to reduce the time it takes to render pages.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['objectcache.enabled']) {
$item['configured'] = true;
$thisclass->set_install_status('object_cache', true);
} else {
$thisclass->set_install_status('object_cache', false);
}
},
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'disable' => function () use (&$thisclass) {
$thisclass->disable_w3tc_object_cache();
},
'enable' => function () use (&$thisclass) {
$thisclass->enable_w3tc_object_cache();
}
),
'browser_cache' => array(
'slug' => 'browser_cache',
'name' => 'Browser Caching with W3 Total Cache',
'plugin' => 'W3 Total Cache',
'configured' => false,
'description' => 'Add Rules to the web server to tell the visitor's browser to store a copy of static files to reduce the load time pages requested after the first page is loaded.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['browsercache.enabled']) {
$item['configured'] = true;
$thisclass->set_install_status('browser_cache', true);
} else {
$thisclass->set_install_status('browser_cache', false);
}
},
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'disable' => function () use (&$thisclass) {
$thisclass->disable_w3tc_browser_cache();
},
'enable' => function () use (&$thisclass) {
$thisclass->enable_w3tc_browser_cache();
}
),
'minify' => array(
'name' => 'Minify HTML Pages',
'slug' => 'minify',
'plugin' => 'W3 Total Cache',
'configured' => false,
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'description' => 'Removes extra spaces,tabs and line breaks in the HTML to reduce the size of the files sent to the user.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['minify.enabled'] && $w3tc['minify.html.enable']) {
$item['configured'] = true;
$thisclass->set_install_status('minify-html', true);
} else {
$thisclass->set_install_status('minify-html', false);
}
},
'enable' => function () use (&$thisclass) {
$thisclass->enable_html_minify();
},
'disable' => function () use (&$thisclass) {
$thisclass->disable_html_minify();
}
),
'css_minify' => array(
'name' => 'Minify CSS Files',
'slug' => 'css_minify',
'plugin' => 'W3 Total Cache',
'configured' => false,
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'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.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['minify.css.enable']) {
$item['configured'] = true;
$thisclass->set_install_status('minify-css', true);
} else {
$thisclass->set_install_status('minify-css', false);
}
},
'enable' => function () use (&$thisclass) {
$thisclass->update_w3tc(array(
'minify.css.enable' => true,
'minify.enabled' => true,
'minify.auto' => 0,
'minify.engine' => 'file'
));
},
'disable' => function () use (&$thisclass) {
$thisclass->update_w3tc(array(
'minify.css.enable' => false,
'minify.auto' => 0
));
}
),
'js_minify' => array(
'name' => 'Minify JS Files',
'slug' => 'js_minify',
'plugin' => 'W3 Total Cache',
'configured' => false,
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'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.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['minify.js.enable']) {
$item['configured'] = true;
$thisclass->set_install_status('minify-js', true);
} else {
$thisclass->set_install_status('minify-js', false);
}
},
'enable' => function () use (&$thisclass) {
$thisclass->update_w3tc(array(
'minify.js.enable' => true,
'minify.enabled' => true,
'minify.auto' => 0,
'minify.engine' => 'file'
));
},
'disable' => function () use (&$thisclass) {
$thisclass->update_w3tc(array(
'minify.js.enable' => false,
'minify.auto' => 0
));
}
),
'gzip' => array(
'name' => 'Gzip Compression Enabled',
'slug' => 'gzip',
'plugin' => 'W3 Total Cache',
'configured' => false,
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-w3-total-cache-and-gtmetrix',
'description' => 'Makes your site significantly faster by compressing all text files to make them smaller.',
'is_configured' => function (&$item) use (&$thisclass) {
$w3tc = $thisclass->get_w3tc_config();
if ($w3tc['browsercache.other.compression']) {
$item['configured'] = true;
$thisclass->set_install_status('gzip', true);
} else {
$thisclass->set_install_status('gzip', false);
}
},
'enable' => function () use (&$thisclass) {
$thisclass->update_w3tc(array(
'browsercache.other.compression' => true,
'browsercache.html.compression' => true,
'browsercache.cssjs.compression' => true
));
},
'disable' => function () use (&$thisclass) {
$thisclass->update_w3tc(array(
'browsercache.other.compression' => false,
'browsercache.html.compression' => false,
'browsercache.cssjs.compression' => false
));
}
),
'htaccess' => array(
'name' => 'Deny Direct Access to Configuration Files and Comment Form',
'slug' => 'htaccess',
'plugin' => 'A2 Optimized',
'configured' => false,
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin',
'description' => 'Protects your configuration files by generating a Forbidden error to web users and bots when trying to access WordPress configuration files.
Also prevents POST requests to the site not originating from a user on the site.
note: if you are using a plugin to allow remote posts and comments, disable this option.',
'is_configured' => function (&$item) use (&$thisclass) {
$htaccess = file_get_contents(ABSPATH . '.htaccess');
if (strpos($htaccess, "# BEGIN WordPress Hardening") === false) {
if ($thisclass->get_deny_direct() == true) {
$thisclass->set_deny_direct(false);
}
//make sure the basic a2-optimized rules are present
$thisclass->set_install_status('htaccess-deny-direct-access', false);
} else {
if ($thisclass->get_deny_direct() == false) {
$thisclass->set_deny_direct(true);
}
$item['configured'] = true;
$thisclass->set_install_status('htaccess-deny-direct-access', true);
}
},
'enable' => function () use (&$thisclass) {
$thisclass->set_deny_direct(true);
$thisclass->write_htaccess();
},
'disable' => function () use (&$thisclass) {
$thisclass->set_deny_direct(false);
$thisclass->write_htaccess();
}
),
'lock' => array(
'name' => 'Lock Editing of Plugins and Themes from the WP Admin',
'slug' => 'lock',
'plugin' => 'A2 Optimized',
'configured' => false,
'kb' => 'http://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/optimizing-wordpress-with-the-a2-optimized-plugin',
'description' => 'Prevents exploits that use the built in editing capabilities of the WP Admin',
'is_configured' => function (&$item) use (&$thisclass) {
$wpconfig = file_get_contents(ABSPATH . 'wp-config.php');
if (strpos($wpconfig, "// BEGIN A2 CONFIG") === false) {
if ($thisclass->get_lockdown() == true) {
$thisclass->get_lockdown(false);
}
$thisclass->set_install_status('lock-editing', false);
} else {
if ($thisclass->get_lockdown() == false) {
$thisclass->set_lockdown(true);
}
$item['configured'] = true;
$thisclass->set_install_status('lock-editing', true);
}
},
'enable' => function () use (&$thisclass) {
$thisclass->set_lockdown(true);
$thisclass->write_wp_config();
},
'disable' => function () use (&$thisclass) {
$thisclass->set_lockdown(false);
$thisclass->write_wp_config();
}
),
'wp-login' => array(
'name' => 'Login URL Change',
'slug' => 'wp-login',
'premium' => true,
'plugin' => 'Rename wp-login.php',
'configured' => false,
'kb' => 'http://www.a2hosting.com/kb/security/application-security/wordpress-security#a-namemethodRenameLoginPageaMethod-3.3A-Change-the-WordPress-login-URL',
'description' => '
Change the URL of your login page to make it harder for bots to find it to brute force attack.
', 'is_configured' => function(){ return false; } ), 'captcha' => array( 'name' => 'reCAPTCHA on comments and login', 'plugin' => 'reCAPTCHA', 'slug' => 'captcha', 'premium' => true, 'configured' => false, '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.', 'is_configured' => function (){ return false; } ), 'images' => array( 'name' => 'Compress Images on Upload', 'plugin' => 'EWWW Image Optimizer', 'slug' => 'images', 'premium' => true, 'configured' => false, 'description' => 'Makes your site faster by compressing images to make them smaller.', 'is_configured' => function () { return false; } ), 'turbo' => array( 'name' => 'Turbo Web Hosting', 'slug' => 'turbo', 'configured' => false, 'premium'=>true, 'description' => 'Plugin that actively keeps track of your WP install and sends you alerts if your site falls below certain criteria. The GTMetrix plugin requires an account with gtmetrix.com
Use this plugin only if your site is experiencing issues with slow load times.
The GTMetrix plugin will slow down your site.
See which plugins are slowing down your site. This plugin creates a performance report for your site.
Use this plugin only if your site is experiencing issues with slow load times.
The P3 plugin will slow down your site.
CloudFlare is a free global CDN and DNS provider that can speed up and protect any site online.