PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | optimizations/optimizetables.php +18 -13 3.2.21 → 4.7.0 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2
3 -if (!defined('WPO_VERSION')) die('No direct access allowed');
3 +if (!defined('ABSPATH')) die('No direct access allowed');
4 4
5 5 class WP_Optimization_optimizetables extends WP_Optimization {
6 6
7 7 protected $auto_id = 'optimize';
@@ -39,12 +39,12 @@
39 39 * Run optimization.
40 40 */
41 41 public function after_optimize() {
42 42 // check if force optimize sent.
43 - $force = (isset($this->data['optimization_force']) && $this->data['optimization_force']) ? true : false;
43 + $force = isset($this->data['optimization_force']) && $this->data['optimization_force'];
44 44
45 45 // check if single table name posted or optimize all tables.
46 - if (isset($this->data['optimization_table']) && '' != $this->data['optimization_table']) {
46 + if (isset($this->data['optimization_table']) && '' !== $this->data['optimization_table']) {
47 47 $table = $this->optimizer->get_table($this->data['optimization_table']);
48 48
49 49 if (false !== $table) {
50 50 $this->optimize_table($table, $force);
@@ -81,8 +81,9 @@
81 81 $this->register_meta('overhead', $overhead_usage);
82 82 $this->register_meta('overhead_formatted', $wp_optimize->format_size($overhead_usage));
83 83 } else {
84 84 $this->register_meta('error', 1);
85 + // translators: %s is a table name
85 86 $this->register_meta('message', sprintf(__('The table "%s" does not exist.', 'wp-optimize'), $this->data['optimization_table']));
86 87 return false;
87 88
88 89 }
@@ -103,9 +104,9 @@
103 104 */
104 105 private function optimize_table($table_obj, $force = false) {
105 106
106 107 // if not forced and table is not optimizable then exit.
107 - if (false == $force && (false == $table_obj->is_optimizable || false == $table_obj->is_type_supported)) return;
108 + if (!$force && (!$table_obj->is_optimizable || !$table_obj->is_type_supported)) return;
108 109
109 110 if ($table_obj->is_type_supported) {
110 111 $this->logger->info('Optimizing: ' . $table_obj->Name);
111 112 $this->query('OPTIMIZE TABLE `' . $table_obj->Name . '`');
@@ -110,9 +111,9 @@
110 111 $this->logger->info('Optimizing: ' . $table_obj->Name);
111 112 $this->query('OPTIMIZE TABLE `' . $table_obj->Name . '`');
112 113
113 114 // For InnoDB Data_free doesn't contain free size.
114 - if ('InnoDB' != $table_obj->Engine) {
115 + if ('InnoDB' !== $table_obj->Engine) {
115 116 $this->optimizer->update_total_cleaned(strval($table_obj->Data_free));
116 117 }
117 118
118 119 $this->register_output(__('Optimized table:', 'wp-optimize') . ' ' . $table_obj->Name);
@@ -130,9 +131,9 @@
130 131 $this->table_information['is_optimizable'] = true;
131 132 }
132 133
133 134 /**
134 - * Get information to be disbalyed onscreen before optimization.
135 + * Get information to be displayed onscreen before optimization.
135 136 */
136 137 public function get_info() {
137 138 $table_information = $this->optimizer->get_table_information(get_current_blog_id());
138 139
@@ -153,9 +154,9 @@
153 154 $tablesstatus = $this->table_information;
154 155
155 156 // Check if database is not optimizable.
156 157 if (false === $tablesstatus['is_optimizable']) {
157 - if (isset($this->data['optimization_table']) && '' != $this->data['optimization_table']) {
158 + if (isset($this->data['optimization_table']) && '' !== $this->data['optimization_table']) {
158 159 // This is used for grabbing information before optimizations.
159 160 $this->register_output(__('Total gain:', 'wp-optimize').' '.WP_Optimize()->format_size(($tablesstatus['total_gain'])));
160 161 }
161 162
@@ -160,27 +161,31 @@
160 161 }
161 162
162 163 if ($tablesstatus['inno_db_tables'] > 0) {
163 164 // Output message for how many InnoDB tables will not be optimized.
164 - $this->register_output(sprintf(__('Tables using the InnoDB engine (%d) will not be optimized.'), $tablesstatus['inno_db_tables']));
165 + // translators: %d is number of InnoDB tables
166 + $this->register_output(sprintf(__('Tables using the InnoDB engine (%d) will not be optimized.', 'wp-optimize'), $tablesstatus['inno_db_tables']));
165 167
166 168 if ($tablesstatus['non_inno_db_tables'] > 0) {
169 + // translators: %s is number of Non InnoDB tables
167 170 $this->register_output(sprintf(__('Other tables will be optimized (%s).', 'wp-optimize'), $tablesstatus['non_inno_db_tables']));
168 171 }
169 172
170 - $faq_url = apply_filters('wpo_faq_url', 'https://getwpo.com/faqs/');
173 + $faq_url = apply_filters('wpo_faq_url', 'https://teamupdraft.com/documentation/wp-optimize/topics/database-optimization/faqs/');
171 174 $force_db_option = $this->options->get_option('innodb-force-optimize', 'false');
172 175 $this->register_output('<input id="innodb_force_optimize" name="innodb-force-optimize" type="checkbox" value="true" '.checked($force_db_option, 'true').'><label for="innodb_force_optimize">'.__('Optimize InnoDB tables anyway.', 'wp-optimize').'</label><br><a href="'.$faq_url.'" target="_blank">'.__('Warning: you should read the FAQ on the risks of this operation first.', 'wp-optimize').'</a>');
173 176 }
174 177 } else {
178 + // translators: %s is number of tables
175 179 $this->register_output(sprintf(__('Tables will be optimized (%s).', 'wp-optimize'), $tablesstatus['non_inno_db_tables'] + $tablesstatus['inno_db_tables']));
176 180 }
177 181 }
178 -
179 - public function get_auto_option_description() {
180 - return __('Optimize database tables', 'wp-optimize');
181 - }
182 182
183 + /**
184 + * Return settings label
185 + *
186 + * @return string
187 + */
183 188 public function settings_label() {
184 189 return __('Optimize database tables', 'wp-optimize');
185 190 }
186 191 }