A2 Optimized WP - Version 2.1.3.1

Version Description

  • Fixed issue with handling of some regex formulas in the advanced cache settings exclusion list
  • Additional checks when adding memcached server for object caching
Download this release

Release Info

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

Code changes from version 2.1.3 to 2.1.3.1

A2_Optimized_Cache.php CHANGED
@@ -1085,7 +1085,8 @@ final class A2_Optimized_Cache {
1085
  */
1086
 
1087
  public static function register_settings() {
1088
- register_setting( 'a2-optimized-wp', 'a2-optimized-wp', array( __CLASS__, 'validate_settings' ) );
 
1089
  }
1090
 
1091
  /**
@@ -1153,4 +1154,46 @@ final class A2_Optimized_Cache {
1153
 
1154
  return $validated_settings;
1155
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1156
  }
1085
  */
1086
 
1087
  public static function register_settings() {
1088
+ register_setting( 'a2opt-cache', 'a2opt-cache', array( __CLASS__, 'validate_settings' ) );
1089
+ register_setting( 'a2opt-cache', 'a2_optimized_memcached_server', array( __CLASS__, 'validate_memcached' ));
1090
  }
1091
 
1092
  /**
1154
 
1155
  return $validated_settings;
1156
  }
1157
+
1158
+ /**
1159
+ * validate memcached settings
1160
+ *
1161
+ * @param string $settings user defined settings
1162
+ * @return string $validated_settings validated settings
1163
+ */
1164
+
1165
+ public static function validate_memcached($memcached_server) {
1166
+ $options_manager = new A2_Optimized_OptionsManager;
1167
+
1168
+ if (class_exists('Memcached')) {
1169
+ $memcached = new Memcached;
1170
+ if ( 'unix://' == substr( $memcached_server, 0, 7 ) ) {
1171
+ $node = str_replace('unix://', '', $memcached_server);
1172
+ $port = 0;
1173
+ } else {
1174
+ list( $node, $port ) = explode( ':', $memcached_server );
1175
+ if ( ! $port ) {
1176
+ $port = ini_get( 'memcache.default_port' );
1177
+ }
1178
+ $port = intval( $port );
1179
+ if ( ! $port ) {
1180
+ $port = 11211;
1181
+ }
1182
+ }
1183
+ $instances[] = array( $node, $port, 1 );
1184
+
1185
+ $memcached->addServers($instances);
1186
+ $memcached_available = $memcached->getStats();
1187
+ if ($memcached_available) {
1188
+ $options_manager->write_wp_config();
1189
+ delete_option('a2_optimized_memcached_invalid');
1190
+ } else {
1191
+ update_option('a2_optimized_memcached_invalid', 'Unable to connect to Memcached Server');
1192
+ }
1193
+ } else {
1194
+ update_option('a2_optimized_memcached_invalid', 'Missing Memcached extension');
1195
+ }
1196
+
1197
+ return $memcached_server;
1198
+ }
1199
  }
A2_Optimized_Optimizations.php CHANGED
@@ -58,6 +58,12 @@ class A2_Optimized_Optimizations {
58
  $thisclass = $this->thisclass;
59
  $thisclass->server_info = $this->server_info;
60
 
 
 
 
 
 
 
61
  if (is_plugin_active('a2-w3-total-cache/a2-w3-total-cache.php')) {
62
  /* W3 Total Cache Caching */
63
  $optimizations = array(
@@ -357,7 +363,7 @@ class A2_Optimized_Optimizations {
357
  <li>Take advantage of A2 Hosting&apos;s one-click memcached configuration for WordPress.</li>
358
  </ul>
359
  <strong>A memcached server and the PHP memcached extension are required.</strong><br /><a href="admin.php?a2-page=cache_settings&page=A2_Optimized_Plugin_admin">Configure Memcached Settings</a>
360
- ',
361
  'is_configured' => function (&$item) use (&$thisclass) {
362
  if (get_option('a2_object_cache_enabled') == 1 && file_exists( WP_CONTENT_DIR . '/object-cache.php')) {
363
  $item['configured'] = true;
58
  $thisclass = $this->thisclass;
59
  $thisclass->server_info = $this->server_info;
60
 
61
+ $a2_object_cache_additional_info = '';
62
+
63
+ if (get_option('a2_optimized_memcached_invalid') || get_option('a2_optimized_memcached_server') == false) {
64
+ $a2_object_cache_additional_info = '<p><strong>Please confirm your memcached server settings before enabling Object Caching.</strong><br />' . get_option('a2_optimized_memcached_invalid') . '</p>';
65
+ }
66
+
67
  if (is_plugin_active('a2-w3-total-cache/a2-w3-total-cache.php')) {
68
  /* W3 Total Cache Caching */
69
  $optimizations = array(
363
  <li>Take advantage of A2 Hosting&apos;s one-click memcached configuration for WordPress.</li>
364
  </ul>
365
  <strong>A memcached server and the PHP memcached extension are required.</strong><br /><a href="admin.php?a2-page=cache_settings&page=A2_Optimized_Plugin_admin">Configure Memcached Settings</a>
366
+ ' . $a2_object_cache_additional_info,
367
  'is_configured' => function (&$item) use (&$thisclass) {
368
  if (get_option('a2_object_cache_enabled') == 1 && file_exists( WP_CONTENT_DIR . '/object-cache.php')) {
369
  $item['configured'] = true;
A2_Optimized_OptionsManager.php CHANGED
@@ -431,6 +431,10 @@ class A2_Optimized_OptionsManager {
431
  *
432
  */
433
  public function enable_a2_object_cache() {
 
 
 
 
434
  copy( A2OPT_DIR . '/object-cache.php', WP_CONTENT_DIR . '/object-cache.php' );
435
 
436
  $this->write_wp_config();
@@ -1655,7 +1659,7 @@ HTML;
1655
  private function cache_settings_html() {
1656
  $image_dir = plugins_url('/assets/images', __FILE__);
1657
  $kb_search_box = $this->kb_searchbox_html();
1658
- $admin_url = admin_url('admin.php?a2-page=cache_settings_save&page=A2_Optimized_Plugin_admin&save_settings=1'); ?>
1659
  <section id="a2opt-content-general">
1660
  <div class="wrap">
1661
  <div>
@@ -1672,9 +1676,12 @@ HTML;
1672
  </div>
1673
  </div>
1674
  <div class="tab-content">
1675
- <?php if (isset($_GET['save_settings']) && $_GET['save_settings'] == 1) { ?>
1676
  <div class="notice notice-success is-dismissible"><p>Settings Saved</p></div>
1677
  <?php } ?>
 
 
 
1678
  <h3>Advanced Cache Settings</h3>
1679
  <div>
1680
  <form method="post" action="<?php echo $admin_url; ?>">
@@ -1819,7 +1826,6 @@ HTML;
1819
  // translators: %s: ,
1820
  printf( esc_html__( 'Address and port of the memcached server for object caching', 'a2-optimized-wp' ), '<code class="code--form-control">,</code>' ); ?>
1821
  </p>
1822
- <p><?php esc_html_e( 'Example:', 'a2-optimized-wp' ); ?> <code class="code--form-control">127.0.0.1:11211</code></p>
1823
  </label>
1824
  </fieldset>
1825
  </td>
431
  *
432
  */
433
  public function enable_a2_object_cache() {
434
+ if (get_option('a2_optimized_memcached_invalid') || get_option('a2_optimized_memcached_server') == false) {
435
+ return false;
436
+ }
437
+
438
  copy( A2OPT_DIR . '/object-cache.php', WP_CONTENT_DIR . '/object-cache.php' );
439
 
440
  $this->write_wp_config();
1659
  private function cache_settings_html() {
1660
  $image_dir = plugins_url('/assets/images', __FILE__);
1661
  $kb_search_box = $this->kb_searchbox_html();
1662
+ $admin_url = 'options.php'; ?>
1663
  <section id="a2opt-content-general">
1664
  <div class="wrap">
1665
  <div>
1676
  </div>
1677
  </div>
1678
  <div class="tab-content">
1679
+ <?php if (isset($_REQUEST['settings-updated']) && $_GET['settings-updated'] == 'true') { ?>
1680
  <div class="notice notice-success is-dismissible"><p>Settings Saved</p></div>
1681
  <?php } ?>
1682
+ <?php if (get_option('a2_optimized_memcached_invalid')) { ?>
1683
+ <div class="notice notice-error"><p>There is an issue with your Memcached settings<br /><?php echo get_option('a2_optimized_memcached_invalid'); ?></p></div>
1684
+ <?php } ?>
1685
  <h3>Advanced Cache Settings</h3>
1686
  <div>
1687
  <form method="post" action="<?php echo $admin_url; ?>">
1826
  // translators: %s: ,
1827
  printf( esc_html__( 'Address and port of the memcached server for object caching', 'a2-optimized-wp' ), '<code class="code--form-control">,</code>' ); ?>
1828
  </p>
 
1829
  </label>
1830
  </fieldset>
1831
  </td>
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.1.3
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.1.3.1
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: 5.1
5
  Tested up to: 5.7.1
6
- Stable tag: 2.1.3
7
  Requires PHP: 5.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -123,6 +123,10 @@ Yes. A2 Optimized works on any host that supports WordPress; however, A2 Hostin
123
 
124
  == Changelog ==
125
 
 
 
 
 
126
  = 2.1 =
127
  * Removed requirement for W3 Total Cache. A2 Optimized now contains it's own caching engine. Don't worry if you still want to use W3 Total Cache, it will continue to work as it always has with this and future updates.
128
  * Memcached object caching is now available on any host that supports it.
3
  Tags: Speed, Optimize, Secure, Fast, W3 Total Cache, W3TC, Hosting
4
  Requires at least: 5.1
5
  Tested up to: 5.7.1
6
+ Stable tag: 2.1.3.1
7
  Requires PHP: 5.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
123
 
124
  == Changelog ==
125
 
126
+ = 2.1.3.1 =
127
+ * Fixed issue with handling of some regex formulas in the advanced cache settings exclusion list
128
+ * Additional checks when adding memcached server for object caching
129
+
130
  = 2.1 =
131
  * Removed requirement for W3 Total Cache. A2 Optimized now contains it's own caching engine. Don't worry if you still want to use W3 Total Cache, it will continue to work as it always has with this and future updates.
132
  * Memcached object caching is now available on any host that supports it.