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/usermeta.php +19 -17 3.3.2 → 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_usermeta extends WP_Optimization {
6 6
7 7 public $ui_sort_order = 8001;
@@ -20,8 +20,10 @@
20 20 * @return array
21 21 */
22 22 public function preview($params) {
23 23 // get data requested for preview.
24 + // `$this->wpdb->prepare` is global `$wpdb->prepare`
25 + // phpcs:disable
24 26 $sql = $this->wpdb->prepare(
25 27 "SELECT um.* FROM `" . $this->wpdb->usermeta . "` um".
26 28 " LEFT JOIN `" . $this->wpdb->users . "` wu ON wu.ID = um.user_id".
27 29 " WHERE wu.ID IS NULL".
@@ -32,13 +34,14 @@
32 34 )
33 35 );
34 36
35 37 $users = $this->wpdb->get_results($sql, ARRAY_A);
38 + // phpcs:enable
36 39
37 40 // get total count user meta for optimization.
38 41 $sql = "SELECT COUNT(*) FROM `" . $this->wpdb->usermeta . "` um LEFT JOIN `" . $this->wpdb->users . "` wu ON wu.ID = um.user_id WHERE wu.ID IS NULL;";
39 42
40 - $total = $this->wpdb->get_var($sql);
43 + $total = $this->wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- safe, no user input used
41 44
42 45 return array(
43 46 'id_key' => 'umeta_id',
44 47 'columns' => array(
@@ -43,16 +46,16 @@
43 46 'id_key' => 'umeta_id',
44 47 'columns' => array(
45 48 'umeta_id' => __('ID', 'wp-optimize'),
46 49 'user_id' => __('User ID', 'wp-optimize'),
47 - 'meta_key' => __('Meta Key', 'wp-optimize'),
48 - 'meta_value' => __('Meta Value', 'wp-optimize'),
50 + 'meta_key' => __('Meta Key', 'wp-optimize'), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- This is not a query
51 + 'meta_value' => __('Meta Value', 'wp-optimize'), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- This is not a query
49 52 ),
50 53 'offset' => $params['offset'],
51 54 'limit' => $params['limit'],
52 55 'total' => $total,
53 56 'data' => $this->htmlentities_array($users, array('ID')),
54 - 'message' => $total > 0 ? '' : __('No orphaned user meta data in your database', 'wp-optimize'),
57 + 'message' => $total > 0 ? '' : __('No orphaned user metadata in your database', 'wp-optimize'),
55 58 );
56 59 }
57 60
58 61 /**
@@ -58,11 +61,13 @@
58 61 /**
59 62 * Do actions after optimize() function.
60 63 */
61 64 public function after_optimize() {
62 - $message = sprintf(_n('%s orphaned user meta data deleted', '%s orphaned user meta data deleted', $this->processed_count, 'wp-optimize'), number_format_i18n($this->processed_count));
65 + // translators: %s is the number of orphaned user metadata deleted
66 + $message = sprintf(_n('%s orphaned user metadata deleted', '%s orphaned user metadata deleted', $this->processed_count, 'wp-optimize'), number_format_i18n($this->processed_count));
63 67
64 68 if ($this->is_multisite_mode()) {
69 + // translators: %s is the number sites
65 70 $message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
66 71 }
67 72
68 73 $this->logger->info($message);
@@ -90,14 +95,16 @@
90 95 * Do actions after get_info() function.
91 96 */
92 97 public function after_get_info() {
93 98 if ($this->found_count) {
94 - $message = sprintf(_n('%s orphaned user meta data in your database', '%s orphaned user meta data in your database', $this->found_count, 'wp-optimize'), number_format_i18n($this->found_count));
99 + // translators: %s is the number of orphaned user metadata
100 + $message = sprintf(_n('%s orphaned user metadata in your database', '%s orphaned user metadata in your database', $this->found_count, 'wp-optimize'), number_format_i18n($this->found_count));
95 101 } else {
96 - $message = __('No orphaned user meta data in your database', 'wp-optimize');
102 + $message = __('No orphaned user metadata in your database', 'wp-optimize');
97 103 }
98 104
99 105 if ($this->is_multisite_mode()) {
106 + // translators: %s is the number sites
100 107 $message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
101 108 }
102 109
103 110 // add preview link to message.
@@ -112,9 +119,9 @@
112 119 * Get count of unoptimized items.
113 120 */
114 121 public function get_info() {
115 122 $sql = "SELECT COUNT(*) FROM `" . $this->wpdb->usermeta . "` um LEFT JOIN `" . $this->wpdb->users . "` wu ON wu.ID = um.user_id WHERE wu.ID IS NULL;";
116 - $usermeta = $this->wpdb->get_var($sql);
123 + $usermeta = $this->wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- safe, no user input used
117 124
118 125 $this->found_count += $usermeta;
119 126 }
120 127
@@ -119,16 +126,11 @@
119 126 }
120 127
121 128 /**
122 129 * Get settings label.
130 + *
131 + * @return string
123 132 */
124 133 public function settings_label() {
125 - return __('Clean user meta data', 'wp-optimize');
126 - }
127 -
128 - /**
129 - * Get auto option description.
130 - */
131 - public function get_auto_option_description() {
132 - return __('Remove orphaned user meta', 'wp-optimize');
134 + return __('Clean user metadata', 'wp-optimize');
133 135 }
134 136 }