A2 Optimized WP - Version 2.1.4.4

Version Description

= 2.0.10.9 = Important security update. Please upgrade immediately.

= 2.0 = New GPL plugin, now updates are through the wordpress.org repository

Download this release

Release Info

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

Code changes from version 2.1.4.2 to 2.1.4.4

A2_Optimized_DB_Optimizations.php CHANGED
@@ -1,18 +1,7 @@
1
  <?php
2
 
3
- //@TODO: Button run optimizations. deactivate hook to remove cron task
4
-
5
  class A2_Optimized_DBOptimizations {
6
  public $wpdb;
7
- public const WP_SETTING = 'a2_db_optimizations';
8
- public const REMOVE_REVISION_POSTS = 'remove_revision_posts';
9
- public const REMOVE_TRASHED_POSTS = 'remove_trashed_posts';
10
- public const REMOVE_SPAM_COMMENTS = 'remove_spam_comments';
11
- public const REMOVE_TRASHED_COMMENTS = 'remove_trashed_comments';
12
- public const REMOVE_EXPIRED_TRANSIENTS = 'remove_expired_transients';
13
- public const OPTIMIZE_TABLES = 'optimize_tables';
14
- public const EXECUTE_OPTIMIZATIONS_HOOK = 'a2_execute_db_optimizations';
15
- public const CRON_ACTIVE = 'cron_active';
16
 
17
  public function __construct() {
18
  if ( ! $this->allow_load() ) {
@@ -39,11 +28,11 @@ class A2_Optimized_DBOptimizations {
39
  * Integration hooks.
40
  */
41
  protected function hooks() {
42
- $toggles = get_option(self::WP_SETTING);
43
- if ($toggles && isset($toggles[self::CRON_ACTIVE]) && $toggles[self::CRON_ACTIVE]) {
44
- add_action(self::EXECUTE_OPTIMIZATIONS_HOOK, [&$this, 'execute_optimizations']);
45
- if (!wp_next_scheduled(self::EXECUTE_OPTIMIZATIONS_HOOK)) {
46
- wp_schedule_event(time(), 'weekly', self::EXECUTE_OPTIMIZATIONS_HOOK);
47
  }
48
  }
49
  }
@@ -63,12 +52,12 @@ class A2_Optimized_DBOptimizations {
63
  */
64
  private static function get_defaults() {
65
  $default_toggles = [
66
- self::REMOVE_REVISION_POSTS => 0,
67
- self::REMOVE_TRASHED_POSTS => 0,
68
- self::REMOVE_SPAM_COMMENTS => 1,
69
- self::REMOVE_TRASHED_COMMENTS => 1,
70
- self::REMOVE_EXPIRED_TRANSIENTS => 1,
71
- self::OPTIMIZE_TABLES => 1
72
  ];
73
 
74
  return $default_toggles;
@@ -76,12 +65,12 @@ class A2_Optimized_DBOptimizations {
76
 
77
  private static function zero_settings() {
78
  $default_toggles = [
79
- self::REMOVE_REVISION_POSTS => 0,
80
- self::REMOVE_TRASHED_POSTS => 0,
81
- self::REMOVE_SPAM_COMMENTS => 0,
82
- self::REMOVE_TRASHED_COMMENTS => 0,
83
- self::REMOVE_EXPIRED_TRANSIENTS => 0,
84
- self::OPTIMIZE_TABLES => 0
85
  ];
86
 
87
  return $default_toggles;
@@ -94,35 +83,35 @@ class A2_Optimized_DBOptimizations {
94
  * @param bool $value Update the setting to true or false
95
  */
96
  public static function set($setting, $value) {
97
- $toggles = get_option(self::WP_SETTING);
98
  $defaults = self::get_defaults();
99
  $combined = wp_parse_args($toggles, $defaults);
100
  $combined[$setting] = $value;
101
- update_option(self::WP_SETTING, $combined);
102
  }
103
 
104
  /**
105
  * Execute optimizations that have been enabled by the user
106
  */
107
  public function execute_optimizations() {
108
- $toggles = get_option(self::WP_SETTING);
109
 
110
- if ($toggles[self::REMOVE_REVISION_POSTS]) {
111
  $this->remove_revisions_posts();
112
  }
113
- if ($toggles[self::REMOVE_TRASHED_POSTS]) {
114
  $this->remove_trashed_posts();
115
  }
116
- if ($toggles[self::REMOVE_SPAM_COMMENTS]) {
117
  $this->remove_spam_comments();
118
  }
119
- if ($toggles[self::REMOVE_TRASHED_COMMENTS]) {
120
  $this->remove_trashed_comments();
121
  }
122
- if ($toggles[self::REMOVE_EXPIRED_TRANSIENTS]) {
123
  $this->remove_expired_transients();
124
  }
125
- if ($toggles[self::OPTIMIZE_TABLES]) {
126
  $this->remove_optimize_tables();
127
  }
128
  }
1
  <?php
2
 
 
 
3
  class A2_Optimized_DBOptimizations {
4
  public $wpdb;
 
 
 
 
 
 
 
 
 
5
 
6
  public function __construct() {
7
  if ( ! $this->allow_load() ) {
28
  * Integration hooks.
29
  */
30
  protected function hooks() {
31
+ $toggles = get_option('a2_db_optimizations');
32
+ if ($toggles && isset($toggles['cron_active']) && $toggles['cron_active']) {
33
+ add_action('a2_execute_db_optimizations', [&$this, 'execute_optimizations']);
34
+ if (!wp_next_scheduled('a2_execute_db_optimizations')) {
35
+ wp_schedule_event(time(), 'weekly', 'a2_execute_db_optimizations');
36
  }
37
  }
38
  }
52
  */
53
  private static function get_defaults() {
54
  $default_toggles = [
55
+ 'remove_revision_posts' => 0,
56
+ 'remove_trashed_posts' => 0,
57
+ 'remove_spam_comments' => 1,
58
+ 'remove_trashed_comments' => 1,
59
+ 'remove_expired_transients' => 1,
60
+ 'optimize_tables' => 1
61
  ];
62
 
63
  return $default_toggles;
65
 
66
  private static function zero_settings() {
67
  $default_toggles = [
68
+ 'remove_revision_posts' => 0,
69
+ 'remove_trashed_posts' => 0,
70
+ 'remove_spam_comments' => 0,
71
+ 'remove_trashed_comments' => 0,
72
+ 'remove_expired_transients' => 0,
73
+ 'optimize_tables' => 0
74
  ];
75
 
76
  return $default_toggles;
83
  * @param bool $value Update the setting to true or false
84
  */
85
  public static function set($setting, $value) {
86
+ $toggles = get_option('a2_db_optimizations');
87
  $defaults = self::get_defaults();
88
  $combined = wp_parse_args($toggles, $defaults);
89
  $combined[$setting] = $value;
90
+ update_option('a2_db_optimizations', $combined);
91
  }
92
 
93
  /**
94
  * Execute optimizations that have been enabled by the user
95
  */
96
  public function execute_optimizations() {
97
+ $toggles = get_option('a2_db_optimizations');
98
 
99
+ if ($toggles['remove_revision_posts']) {
100
  $this->remove_revisions_posts();
101
  }
102
+ if ($toggles['remove_trashed_posts']) {
103
  $this->remove_trashed_posts();
104
  }
105
+ if ($toggles['remove_spam_comments']) {
106
  $this->remove_spam_comments();
107
  }
108
+ if ($toggles['remove_trashed_comments']) {
109
  $this->remove_trashed_comments();
110
  }
111
+ if ($toggles['remove_expired_transients']) {
112
  $this->remove_expired_transients();
113
  }
114
+ if ($toggles['optimize_tables']) {
115
  $this->remove_optimize_tables();
116
  }
117
  }
A2_Optimized_Optimizations.php CHANGED
@@ -440,8 +440,8 @@ class A2_Optimized_Optimizations {
440
  'description' => 'If enabled, will periodically clean the MySQL database of expired transients, trashed comments, spam comments, and optimize all tables. You may also select to remove post revisions and trashed posts from the Database Optimization Settings.<br />
441
  <a href="admin.php?a2-page=cache_settings&page=A2_Optimized_Plugin_admin">Configure Database Optimization Settings</a>',
442
  'is_configured' => function (&$item) use (&$thisclass) {
443
- $toggles = get_option(A2_Optimized_DBOptimizations::WP_SETTING);
444
- if (isset($toggles[A2_Optimized_DBOptimizations::CRON_ACTIVE]) && $toggles[A2_Optimized_DBOptimizations::CRON_ACTIVE]) {
445
  $item['configured'] = true;
446
  $thisclass->set_install_status('a2-db-optimizations', true);
447
  } else {
@@ -449,10 +449,10 @@ class A2_Optimized_Optimizations {
449
  }
450
  },
451
  'enable' => function () use (&$thisclass) {
452
- A2_Optimized_DBOptimizations::set(A2_Optimized_DBOptimizations::CRON_ACTIVE, true);
453
  },
454
  'disable' => function () use (&$thisclass) {
455
- A2_Optimized_DBOptimizations::set(A2_Optimized_DBOptimizations::CRON_ACTIVE, false);
456
  },
457
  ],
458
  'woo-cart-fragments' => [
440
  'description' => 'If enabled, will periodically clean the MySQL database of expired transients, trashed comments, spam comments, and optimize all tables. You may also select to remove post revisions and trashed posts from the Database Optimization Settings.<br />
441
  <a href="admin.php?a2-page=cache_settings&page=A2_Optimized_Plugin_admin">Configure Database Optimization Settings</a>',
442
  'is_configured' => function (&$item) use (&$thisclass) {
443
+ $toggles = get_option('a2_db_optimizations');
444
+ if (isset($toggles['cron_active']) && $toggles['cron_active']) {
445
  $item['configured'] = true;
446
  $thisclass->set_install_status('a2-db-optimizations', true);
447
  } else {
449
  }
450
  },
451
  'enable' => function () use (&$thisclass) {
452
+ A2_Optimized_DBOptimizations::set('cron_active', true);
453
  },
454
  'disable' => function () use (&$thisclass) {
455
+ A2_Optimized_DBOptimizations::set('cron_active', false);
456
  },
457
  ],
458
  'woo-cart-fragments' => [
A2_Optimized_OptionsManager.php CHANGED
@@ -1730,7 +1730,7 @@ HTML;
1730
  $image_dir = plugins_url('/assets/images', __FILE__);
1731
  $kb_search_box = $this->kb_searchbox_html();
1732
  $admin_url = 'options.php';
1733
- $db_optimization_settings = get_option(A2_Optimized_DBOptimizations::WP_SETTING); ?>
1734
  <section id="a2opt-content-general">
1735
  <div class="wrap">
1736
  <div>
@@ -1942,42 +1942,42 @@ HTML;
1942
  <td>
1943
  <fieldset>
1944
  <label for="remove_revision_posts">
1945
- <input name="a2_db_optimizations[remove_revision_posts]" type="checkbox" id="remove_revision_posts" value="1" <?php checked( '1', $db_optimization_settings[A2_Optimized_DBOptimizations::REMOVE_REVISION_POSTS] ); ?> />
1946
  <?php esc_html_e( 'Delete all history of post revisions', 'a2-optimized-wp' ); ?>
1947
  </label>
1948
 
1949
  <br />
1950
 
1951
  <label for="remove_trashed_posts">
1952
- <input name="a2_db_optimizations[remove_trashed_posts]" type="checkbox" id="remove_trashed_posts" value="1" <?php checked( '1', $db_optimization_settings[A2_Optimized_DBOptimizations::REMOVE_TRASHED_POSTS] ); ?> />
1953
  <?php esc_html_e( 'Permanently delete all posts in trash', 'a2-optimized-wp' ); ?>
1954
  </label>
1955
 
1956
  <br />
1957
 
1958
  <label for="remove_spam_comments">
1959
- <input name="a2_db_optimizations[remove_spam_comments]" type="checkbox" id="remove_spam_comments" value="1" <?php checked( '1', $db_optimization_settings[A2_Optimized_DBOptimizations::REMOVE_SPAM_COMMENTS] ); ?> />
1960
  <?php esc_html_e( 'Delete all comments marked as spam', 'a2-optimized-wp' ); ?>
1961
  </label>
1962
 
1963
  <br />
1964
 
1965
  <label for="remove_trashed_comments">
1966
- <input name="a2_db_optimizations[remove_trashed_comments]" type="checkbox" id="remove_trashed_comments" value="1" <?php checked( '1', $db_optimization_settings[A2_Optimized_DBOptimizations::REMOVE_TRASHED_COMMENTS] ); ?> />
1967
  <?php esc_html_e( 'Permanently delete all comments in trash', 'a2-optimized-wp' ); ?>
1968
  </label>
1969
 
1970
  <br />
1971
 
1972
  <label for="remove_expired_transients">
1973
- <input name="a2_db_optimizations[remove_expired_transients]" type="checkbox" id="remove_expired_transients" value="1" <?php checked( '1', $db_optimization_settings[A2_Optimized_DBOptimizations::REMOVE_EXPIRED_TRANSIENTS] ); ?> />
1974
  <?php esc_html_e( 'Delete temporary data that has expired', 'a2-optimized-wp' ); ?>
1975
  </label>
1976
 
1977
  <br />
1978
 
1979
  <label for="optimize_tables">
1980
- <input name="a2_db_optimizations[optimize_tables]" type="checkbox" id="optimize_tables" value="1" <?php checked( '1', $db_optimization_settings[A2_Optimized_DBOptimizations::OPTIMIZE_TABLES] ); ?> />
1981
  <?php esc_html_e( 'Perform optimizations on all database tables', 'a2-optimized-wp' ); ?>
1982
  </label>
1983
 
1730
  $image_dir = plugins_url('/assets/images', __FILE__);
1731
  $kb_search_box = $this->kb_searchbox_html();
1732
  $admin_url = 'options.php';
1733
+ $db_optimization_settings = get_option('a2_db_optimizations'); ?>
1734
  <section id="a2opt-content-general">
1735
  <div class="wrap">
1736
  <div>
1942
  <td>
1943
  <fieldset>
1944
  <label for="remove_revision_posts">
1945
+ <input name="a2_db_optimizations[remove_revision_posts]" type="checkbox" id="remove_revision_posts" value="1" <?php checked( '1', $db_optimization_settings['remove_revision_posts'] ); ?> />
1946
  <?php esc_html_e( 'Delete all history of post revisions', 'a2-optimized-wp' ); ?>
1947
  </label>
1948
 
1949
  <br />
1950
 
1951
  <label for="remove_trashed_posts">
1952
+ <input name="a2_db_optimizations[remove_trashed_posts]" type="checkbox" id="remove_trashed_posts" value="1" <?php checked( '1', $db_optimization_settings['remove_trashed_posts'] ); ?> />
1953
  <?php esc_html_e( 'Permanently delete all posts in trash', 'a2-optimized-wp' ); ?>
1954
  </label>
1955
 
1956
  <br />
1957
 
1958
  <label for="remove_spam_comments">
1959
+ <input name="a2_db_optimizations[remove_spam_comments]" type="checkbox" id="remove_spam_comments" value="1" <?php checked( '1', $db_optimization_settings['remove_spam_comments'] ); ?> />
1960
  <?php esc_html_e( 'Delete all comments marked as spam', 'a2-optimized-wp' ); ?>
1961
  </label>
1962
 
1963
  <br />
1964
 
1965
  <label for="remove_trashed_comments">
1966
+ <input name="a2_db_optimizations[remove_trashed_comments]" type="checkbox" id="remove_trashed_comments" value="1" <?php checked( '1', $db_optimization_settings['remove_trashed_comments'] ); ?> />
1967
  <?php esc_html_e( 'Permanently delete all comments in trash', 'a2-optimized-wp' ); ?>
1968
  </label>
1969
 
1970
  <br />
1971
 
1972
  <label for="remove_expired_transients">
1973
+ <input name="a2_db_optimizations[remove_expired_transients]" type="checkbox" id="remove_expired_transients" value="1" <?php checked( '1', $db_optimization_settings['remove_expired_transients'] ); ?> />
1974
  <?php esc_html_e( 'Delete temporary data that has expired', 'a2-optimized-wp' ); ?>
1975
  </label>
1976
 
1977
  <br />
1978
 
1979
  <label for="optimize_tables">
1980
+ <input name="a2_db_optimizations[optimize_tables]" type="checkbox" id="optimize_tables" value="1" <?php checked( '1', $db_optimization_settings['optimize_tables'] ); ?> />
1981
  <?php esc_html_e( 'Perform optimizations on all database tables', 'a2-optimized-wp' ); ?>
1982
  </label>
1983
 
A2_Optimized_Plugin.php CHANGED
@@ -159,7 +159,7 @@ class A2_Optimized_Plugin extends A2_Optimized_OptionsManager {
159
  }
160
 
161
  // deactivate the scheduled weekly database optimizations
162
- wp_clear_scheduled_hook(A2_Optimized_DBOptimizations::EXECUTE_OPTIMIZATIONS_HOOK);
163
  }
164
 
165
  public function upgrade() {
159
  }
160
 
161
  // deactivate the scheduled weekly database optimizations
162
+ wp_clear_scheduled_hook('a2_execute_db_optimizations');
163
  }
164
 
165
  public function upgrade() {
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.4.2
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.4.4
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, LiteSpeed, LSCache, A2, Hosting
4
  Requires at least: 5.1
5
  Tested up to: 6.0
6
- Stable tag: 2.1.4.2
7
  Requires PHP: 7.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
3
  Tags: Speed, Optimize, Secure, Fast, LiteSpeed, LSCache, A2, Hosting
4
  Requires at least: 5.1
5
  Tested up to: 6.0
6
+ Stable tag: 2.1.4.4
7
  Requires PHP: 7.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html