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/pingbacks.php +16 -4 3.2.9 → 4.7.0 View file →
@@ -1,10 +1,12 @@
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_pingbacks extends WP_Optimization {
6 6
7 + public $available_for_auto = true;
8 +
7 9 public $ui_sort_order = 6000;
8 10
9 11 public $available_for_saving = true;
10 12
@@ -17,8 +19,10 @@
17 19 */
18 20 public function preview($params) {
19 21
20 22 // get data requested for preview.
23 + // `$this->wpdb` is `$wpdb`
24 + // phpcs:disable
21 25 $sql = $this->wpdb->prepare(
22 26 "SELECT comment_ID, comment_author, SUBSTR(comment_content, 1, 128) AS comment_content FROM `" . $this->wpdb->comments . "`".
23 27 " WHERE comment_type = 'pingback'".
24 28 " ORDER BY `comment_ID` LIMIT %d, %d;",
@@ -28,14 +32,15 @@
28 32 )
29 33 );
30 34
31 35 $posts = $this->wpdb->get_results($sql, ARRAY_A);
36 + // phpcs:enable
32 37
33 38 // fix empty revision titles.
34 39 if (!empty($posts)) {
35 40 foreach ($posts as $key => $post) {
36 41 $posts[$key]['post_title'] = array(
37 - 'text' => '' == $post['post_title'] ? '('.__('no title', 'wp-optimize').')' : $post['post_title'],
42 + 'text' => '' === $post['post_title'] ? '('.__('no title', 'wp-optimize').')' : $post['post_title'],
38 43 'url' => get_edit_post_link($post['ID']),
39 44 );
40 45 }
41 46 }
@@ -42,9 +47,9 @@
42 47
43 48 // get total count comments for optimization.
44 49 $sql = "SELECT COUNT(*) FROM `" . $this->wpdb->comments . "` WHERE comment_type = 'pingback';";
45 50
46 - $total = $this->wpdb->get_var($sql);
51 + $total = $this->wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- SQL is safe, no user input used
47 52
48 53 return array(
49 54 'id_key' => 'comment_ID',
50 55 'columns' => array(
@@ -63,11 +68,13 @@
63 68 /**
64 69 * Do actions after optimize() function.
65 70 */
66 71 public function after_optimize() {
72 + // translators: %s is number of pingback deleted
67 73 $message = sprintf(_n('%s pingback deleted', '%s pingbacks deleted', $this->processed_count, 'wp-optimize'), number_format_i18n($this->processed_count));
68 74
69 75 if ($this->is_multisite_mode()) {
76 + // translators: %s is number of sites
70 77 $message .= ' '.sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
71 78 }
72 79
73 80 $this->logger->info($message);
@@ -107,8 +114,9 @@
107 114 * Do actions after get_info() function.
108 115 */
109 116 public function after_get_info() {
110 117 if ($this->found_count > 0) {
118 + // translators: %s is number of pingbacks
111 119 $message = sprintf(_n('%s pingback found', '%s pingbacks found', $this->found_count, 'wp-optimize'), number_format_i18n($this->found_count));
112 120 } else {
113 121 $message = __('No pingbacks found', 'wp-optimize');
114 122 }
@@ -113,8 +121,9 @@
113 121 $message = __('No pingbacks found', 'wp-optimize');
114 122 }
115 123
116 124 if ($this->is_multisite_mode()) {
125 + // translators: %s is number of sites
117 126 $message .= ' '.sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
118 127 }
119 128
120 129 // add preview link to message.
@@ -130,12 +139,15 @@
130 139 */
131 140 public function get_info() {
132 141 $sql = "SELECT COUNT(*) FROM `" . $this->wpdb->comments . "` WHERE comment_type='pingback';";
133 142
134 - $comments = $this->wpdb->get_var($sql);
143 + $comments = $this->wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- SQL is safe, no user input used
135 144 $this->found_count += $comments;
136 145 }
137 146
147 + /**
148 + * Get settings label.
149 + */
138 150 public function settings_label() {
139 151 return __('Remove pingbacks', 'wp-optimize');
140 152 }
141 153 }