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/orphandata.php +14 -3 3.2.20 → 4.7.0 View file →
@@ -1,12 +1,14 @@
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_orphandata extends WP_Optimization {
6 6
7 7 public $ui_sort_order = 10000;
8 8
9 + public $available_for_auto = true;
10 +
9 11 public $available_for_saving = true;
10 12
11 13 public $support_preview = false;
12 14
@@ -13,11 +15,13 @@
13 15 /**
14 16 * Do actions after optimize() function.
15 17 */
16 18 public function after_optimize() {
19 + // translators: %s - number of deleted orphaned relationship data
17 20 $message = sprintf(_n('%s orphaned relationship data deleted', '%s orphaned relationship data deleted', $this->processed_count, 'wp-optimize'), number_format_i18n($this->processed_count));
18 21
19 22 if ($this->is_multisite_mode()) {
23 + // translators: %s - number of sites
20 24 $message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
21 25 }
22 26
23 27 $this->logger->info($message);
@@ -38,8 +42,9 @@
38 42 * Do actions after get_info() function.
39 43 */
40 44 public function after_get_info() {
41 45 if ($this->found_count > 0) {
46 + // translators: %s - number of orphaned relationship data
42 47 $message = sprintf(_n('%s orphaned relationship data in your database', '%s orphaned relationship data in your database', $this->found_count, 'wp-optimize'), number_format_i18n($this->found_count));
43 48 } else {
44 49 $message = __('No orphaned relationship data in your database', 'wp-optimize');
45 50 }
@@ -44,8 +49,9 @@
44 49 $message = __('No orphaned relationship data in your database', 'wp-optimize');
45 50 }
46 51
47 52 if ($this->is_multisite_mode()) {
53 + // translators: %s - number of sites
48 54 $message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
49 55 }
50 56
51 57 $this->register_output($message);
@@ -54,14 +60,19 @@
54 60 /**
55 61 * Get count of unoptimized items.
56 62 */
57 63 public function get_info() {
58 - $sql = "SELECT COUNT(*) FROM `" . $this->wpdb->term_relationships . "` WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM `" . $this->wpdb->posts . "`);";
59 - $orphandata = $this->wpdb->get_var($sql);
64 + $sql = "SELECT COUNT(*) FROM `{$this->wpdb->term_relationships}` WHERE term_taxonomy_id=%d AND object_id NOT IN (SELECT id FROM `{$this->wpdb->posts}`);";
65 + $orphandata = $this->wpdb->get_var($this->wpdb->prepare($sql, 1)); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- `$this->wpdb` is `$wpdb`
60 66
61 67 $this->found_count += $orphandata;
62 68 }
63 69
70 + /**
71 + * Returns settings label
72 + *
73 + * @return string
74 + */
64 75 public function settings_label() {
65 76 return __('Clean orphaned relationship data', 'wp-optimize');
66 77 }
67 78 }