GRAYBYTE WORDPRESS FILE MANAGER4121

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/swamivivekananda.co.in/wp-content/plugins/wp-optimize/optimizations/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/swamivivekananda.co.in/wp-content/plugins/wp-optimize/optimizations//postmeta.php
<?php

if (!defined('WPO_VERSION')) die('No direct access allowed');

class WP_Optimization_postmeta extends WP_Optimization {

	public $ui_sort_order = 8000;

	public $available_for_auto = false;

	public $available_for_saving = true;

	public $auto_default = false;

	/**
	 * Prepare data for preview widget.
	 *
	 * @param array $params
	 *
	 * @return array
	 */
	public function preview($params) {
		// get data requested for preview.
		// `$this->wpdb->prepare` is `$wpdb->prepare` from global variable.
		// phpcs:disable
		$sql = $this->wpdb->prepare(
			"SELECT pm.* FROM `" . $this->wpdb->postmeta . "` pm".
			" LEFT JOIN `" . $this->wpdb->posts . "` wp ON wp.ID = pm.post_id".
			" WHERE wp.ID IS NULL".
			" ORDER BY pm.meta_id LIMIT %d, %d;",
			array(
				$params['offset'],
				$params['limit'],
			)
		);

		$posts = $this->wpdb->get_results($sql, ARRAY_A);
		// phpcs:enable

		// get total count post meta for optimization.
		$sql = "SELECT COUNT(*) FROM `" . $this->wpdb->postmeta . "` pm LEFT JOIN `" . $this->wpdb->posts . "` wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;";

		$total = $this->wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Statement is safe, no user input used

		return array(
			'id_key' => 'meta_id',
			'columns' => array(
				'meta_id' => __('ID', 'wp-optimize'),
				'post_id' => __('Post ID', 'wp-optimize'),
				'meta_key' => __('Meta Key', 'wp-optimize'), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- This is not a query
				'meta_value' => __('Meta Value', 'wp-optimize'), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- This is not a query
			),
			'offset' => $params['offset'],
			'limit' => $params['limit'],
			'total' => $total,
			'data' => $this->htmlentities_array($posts, array('ID')),
			'message' => $total > 0 ? '' : __('No orphaned post meta data in your database', 'wp-optimize'),
		);
	}

	/**
	 * Do actions after optimize() function.
	 */
	public function after_optimize() {
		// translators: %s: number of orphaned post metadata records
		$message = sprintf(_n('%s orphaned post meta data deleted', '%s orphaned post meta data deleted', $this->processed_count, 'wp-optimize'), number_format_i18n($this->processed_count));

		if ($this->is_multisite_mode()) {
			// translators: %s: number of sites
			$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 pm FROM `" . $this->wpdb->postmeta . "` pm LEFT JOIN `" . $this->wpdb->posts . "` wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL";

		// if posted ids in params, then remove only selected items. used by preview widget.
		if (isset($this->data['ids'])) {
			$clean .= ' AND pm.meta_id in ('.join(',', $this->data['ids']).')';
		}

		$clean .= ";";

		$postmeta = $this->query($clean);
		$this->processed_count += $postmeta;
	}

	/**
	 * Do actions after get_info() function.
	 */
	public function after_get_info() {
		if ($this->found_count) {
			// translators: %s: number of orphaned post metadata records
			$message = sprintf(_n('%s orphaned post meta data in your database', '%s orphaned post meta data in your database', $this->found_count, 'wp-optimize'), number_format_i18n($this->found_count));
		} else {
			$message = __('No orphaned post meta data in your database', 'wp-optimize');
		}

		if ($this->is_multisite_mode()) {
			// translators: %s: number of sites
			$message .= ' ' . sprintf(_n('across %s site', 'across %s sites', count($this->blogs_ids), 'wp-optimize'), count($this->blogs_ids));
		}

		// add preview link to message.
		if ($this->found_count > 0) {
			$message = $this->get_preview_link($message);
		}

		$this->register_output($message);
	}

	/**
	 * Get count of unoptimized items.
	 */
	public function get_info() {
		$sql = "SELECT COUNT(*) FROM `" . $this->wpdb->postmeta . "` pm LEFT JOIN `" . $this->wpdb->posts . "` wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;";
		$postmeta = $this->wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Statement is safe, no user input used

		$this->found_count += $postmeta;
	}

	public function settings_label() {
		return __('Clean post meta data', 'wp-optimize');
	}

	/**
	 * N.B. This is not currently used; it was commented out in 1.9.1
	 *
	 * @return string Returns the description once auto remove option has ran
	 */
	public function get_auto_option_description() {
		return __('Remove orphaned post meta', 'wp-optimize');
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:27
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:28
giriqfky / giriqfky
0644
attachments.php
3.147 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
autodraft.php
5.331 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
commentmeta.php
7.538 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
inactive-tags.php
0.556 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
optimizetables.php
6.644 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
orphandata.php
2.394 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
orphanedtables.php
5.421 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
pingbacks.php
4.508 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
postmeta.php
4.561 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
repairtables.php
4.381 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
revisions.php
8.074 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
spam.php
8.172 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
trackbacks.php
4.406 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
transient.php
14.432 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
trash.php
6.781 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
unapproved.php
5.939 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
usermeta.php
4.456 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF