PluginProbe ʕ •ᴥ•ʔ
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.0.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.0.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 3.8.0 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 3.2.2 trunk 0.7.0 1.8.9.10 1.8.9.7 1.8.9.8 1.8.9.9 1.9 1.9.1 2.0.1 2.1.0 2.1.1 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.2 2.2.3 2.2.4 2.2.6 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.18 3.0.19 3.0.2 3.0.3 3.0.4 3.0.5 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.2 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19
wp-optimize / optimizations / orphandata.php
wp-optimize / optimizations Last commit date
attachments.php 8 years ago autodraft.php 7 years ago commentmeta.php 7 years ago inactive-tags.php 8 years ago optimizetables.php 7 years ago orphandata.php 6 years ago orphanedtables.php 7 years ago pingbacks.php 7 years ago postmeta.php 7 years ago repairtables.php 7 years ago revisions.php 7 years ago spam.php 7 years ago trackbacks.php 7 years ago transient.php 7 years ago trash.php 7 years ago unapproved.php 7 years ago
orphandata.php
68 lines
1 <?php
2
3 if (!defined('WPO_VERSION')) die('No direct access allowed');
4
5 class WP_Optimization_orphandata extends WP_Optimization {
6
7 public $ui_sort_order = 10000;
8
9 public $available_for_saving = true;
10
11 public $support_preview = false;
12
13 /**
14 * Do actions after optimize() function.
15 */
16 public function after_optimize() {
17 $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
19 if ($this->is_multisite_mode()) {
20 $message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
21 }
22
23 $this->logger->info($message);
24 $this->register_output($message);
25 }
26
27 /**
28 * Do optimization.
29 */
30 public function optimize() {
31 $clean = "DELETE FROM `" . $this->wpdb->term_relationships . "` WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM `" . $this->wpdb->posts . "`);";
32
33 $orphandata = $this->query($clean);
34 $this->processed_count += $orphandata;
35 }
36
37 /**
38 * Do actions after get_info() function.
39 */
40 public function after_get_info() {
41 if ($this->found_count > 0) {
42 $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 } else {
44 $message = __('No orphaned relationship data in your database', 'wp-optimize');
45 }
46
47 if ($this->is_multisite_mode()) {
48 $message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
49 }
50
51 $this->register_output($message);
52 }
53
54 /**
55 * Get count of unoptimized items.
56 */
57 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);
60
61 $this->found_count += $orphandata;
62 }
63
64 public function settings_label() {
65 return __('Clean orphaned relationship data', 'wp-optimize');
66 }
67 }
68