| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('WPO_VERSION')) die('No direct access allowed'); |
| 4 |
|
| 5 |
class WP_Optimization_trackbacks extends WP_Optimization { |
| 6 |
|
| 7 |
public $ui_sort_order = 7000; |
| 8 |
|
| 9 |
/** |
| 10 |
* Do actions after optimize() function. |
| 11 |
*/ |
| 12 |
public function after_optimize() { |
| 13 |
$message = sprintf(_n('%s trackback deleted', '%s trackbacks deleted', $this->processed_count, 'wp-optimize'), number_format_i18n($this->processed_count)); |
| 14 |
|
| 15 |
if ($this->is_multisite_mode()) { |
| 16 |
$message .= ' '. sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids)); |
| 17 |
} |
| 18 |
|
| 19 |
$this->logger->info($message); |
| 20 |
$this->register_output($message); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Do optimization. |
| 25 |
*/ |
| 26 |
public function optimize() { |
| 27 |
$clean = "DELETE c, cm FROM `" . $this->wpdb->comments . "` c LEFT JOIN `" . $this->wpdb->commentmeta . "` cm ON c.comment_ID = cm.comment_id WHERE comment_type = 'trackback';"; |
| 28 |
|
| 29 |
$comments = $this->query($clean); |
| 30 |
$this->processed_count += $comments; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Do actions after get_info() function. |
| 35 |
*/ |
| 36 |
public function after_get_info() { |
| 37 |
if ($this->found_count) { |
| 38 |
$message = sprintf(_n('%s Trackback found', '%s Trackbacks found', $this->found_count, 'wp-optimize'), number_format_i18n($this->found_count)); |
| 39 |
} else { |
| 40 |
$message = __('No trackbacks found', 'wp-optimize'); |
| 41 |
} |
| 42 |
|
| 43 |
if ($this->is_multisite_mode()) { |
| 44 |
$message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids)); |
| 45 |
} |
| 46 |
|
| 47 |
$this->register_output($message); |
| 48 |
} |
| 49 |
|
| 50 |
public function get_info() { |
| 51 |
$sql = "SELECT COUNT(*) FROM `" . $this->wpdb->comments . "` WHERE comment_type='trackback';"; |
| 52 |
|
| 53 |
$comments = $this->wpdb->get_var($sql); |
| 54 |
$this->found_count += $comments; |
| 55 |
} |
| 56 |
|
| 57 |
public function settings_label() { |
| 58 |
return __('Remove trackbacks', 'wp-optimize'); |
| 59 |
} |
| 60 |
} |
| 61 |
|