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/repairtables.php +15 -10 3.2.20 → 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_repairtables extends WP_Optimization {
6 6
7 7 public $available_for_auto = false;
@@ -27,9 +27,9 @@
27 27 * Run optimization.
28 28 */
29 29 public function optimize() {
30 30 // check if single table name posted or optimize all tables.
31 - if (isset($this->data['optimization_table']) && '' != $this->data['optimization_table']) {
31 + if (isset($this->data['optimization_table']) && '' !== $this->data['optimization_table']) {
32 32 $table = $this->optimizer->get_table($this->data['optimization_table']);
33 33
34 34 $result = (false === $table) ? false : $this->repair_table($table);
35 35
@@ -59,9 +59,9 @@
59 59 $tables = $this->optimizer->get_tables();
60 60 $repaired = $corrupted = 0;
61 61
62 62 foreach ($tables as $table) {
63 - if (false == $table->is_needing_repair) continue;
63 + if (!$table->is_needing_repair) continue;
64 64
65 65 if ($this->repair_table($table)) {
66 66 $repaired++;
67 67 } else {
@@ -68,12 +68,14 @@
68 68 $corrupted++;
69 69 }
70 70 }
71 71
72 - $this->register_output(sprintf(_n('%s table repaired', '%s tables repaired', $repaired), $repaired));
72 + // translators: %s is number of tables repaired.
73 + $this->register_output(sprintf(_n('%s table repaired', '%s tables repaired', $repaired, 'wp-optimize'), $repaired));
73 74
74 75 if ($corrupted > 0) {
75 - $this->register_output(sprintf(_n('Repairing %s table was unsuccessful', 'Repairing %s tables were unsuccessful', $corrupted), $corrupted));
76 + // translators: %s is number of tables
77 + $this->register_output(sprintf(_n('Repairing %s table was unsuccessful', 'Repairing %s tables were unsuccessful', $corrupted, 'wp-optimize'), $corrupted));
76 78 }
77 79 }
78 80 }
79 81
@@ -88,17 +90,17 @@
88 90 global $wpdb;
89 91
90 92 $success = false;
91 93
92 - if (false == $table_obj->is_needing_repair) return true;
94 + if (!$table_obj->is_needing_repair) return true;
93 95
94 96 $this->logger->info('REPAIR TABLE `'.$table_obj->Name. '`');
95 97
96 - $results = $wpdb->get_results('REPAIR TABLE `'.$table_obj->Name . '`');
98 + $results = $wpdb->get_results('REPAIR TABLE `'. esc_sql($table_obj->Name) . '`');
97 99
98 100 if (!empty($results)) {
99 101 foreach ($results as $row) {
100 - if ('status' == strtolower($row->Msg_type) && 'ok' == strtolower($row->Msg_text)) {
102 + if ('status' === strtolower($row->Msg_type) && 'ok' === strtolower($row->Msg_text)) {
101 103 $success = true;
102 104 }
103 105
104 106 $this->logger->info($row->Msg_text);
@@ -113,8 +115,10 @@
113 115
114 116 /**
115 117 * Returns count of corrupted tables and update corrupted-tables-count value in options used to show
116 118 * information for user in sidebar about corrupted tables count.
119 + *
120 + * @return int
117 121 */
118 122 public function get_corrupted_tables_count() {
119 123 $tablesinfo = $this->optimizer->get_tables();
120 124
@@ -140,12 +144,13 @@
140 144 public function get_info() {
141 145
142 146 $corrupted_tables = $this->get_corrupted_tables_count();
143 147
144 - if (0 == $corrupted_tables) {
148 + if (0 === $corrupted_tables) {
145 149 $this->register_output(__('No corrupted tables found', 'wp-optimize'));
146 150 } else {
147 - $this->register_output(sprintf(_n('%s corrupted table found', '%s corrupted tables found', $corrupted_tables), $corrupted_tables));
151 + // translators: %s is number of corrupted tables
152 + $this->register_output(sprintf(_n('%s corrupted table found', '%s corrupted tables found', $corrupted_tables, 'wp-optimize'), $corrupted_tables));
148 153 }
149 154 }
150 155
151 156 /**