| Server IP : 192.241.186.36 / Your IP : 216.73.216.172 Web Server : Apache/2.4.29 (Ubuntu) System : Linux webserver7 4.15.0-194-generic #205-Ubuntu SMP Fri Sep 16 19:49:27 UTC 2022 x86_64 User : root ( 0) PHP Version : 7.4.32 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/adsonicdigital/wp-content/plugins/wp-optimize/optimizations/ |
Upload File : |
<?php
if (!defined('WPO_VERSION')) die('No direct access allowed');
class WP_Optimization_orphandata extends WP_Optimization {
public $ui_sort_order = 10000;
public $available_for_saving = true;
public $support_preview = false;
/**
* Do actions after optimize() function.
*/
public function after_optimize() {
$message = sprintf(_n('%s orphaned relationship data deleted', '%s orphaned relationship data deleted', $this->processed_count, 'wp-optimize'), number_format_i18n($this->processed_count));
if ($this->is_multisite_mode()) {
$message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
}
$this->logger->info($message);
$this->register_output($message);
}
/**
* Do optimization.
*/
public function optimize() {
$clean = "DELETE FROM `" . $this->wpdb->term_relationships . "` WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM `" . $this->wpdb->posts . "`);";
$orphandata = $this->query($clean);
$this->processed_count += $orphandata;
}
/**
* Do actions after get_info() function.
*/
public function after_get_info() {
if ($this->found_count > 0) {
$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));
} else {
$message = __('No orphaned relationship data in your database', 'wp-optimize');
}
if ($this->is_multisite_mode()) {
$message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
}
$this->register_output($message);
}
/**
* Get count of unoptimized items.
*/
public function get_info() {
$sql = "SELECT COUNT(*) FROM `" . $this->wpdb->term_relationships . "` WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM `" . $this->wpdb->posts . "`);";
$orphandata = $this->wpdb->get_var($sql);
$this->found_count += $orphandata;
}
public function settings_label() {
return __('Clean orphaned relationship data', 'wp-optimize');
}
}