GRAYBYTE WORDPRESS FILE MANAGER5122

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
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/chahida.co.in/wp-content/plugins/wp-optimize/webp/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/chahida.co.in/wp-content/plugins/wp-optimize/webp//class-wp-optimize-webp-images.php
<?php
if (!defined('WPO_VERSION')) die('No direct access allowed');

if (!class_exists('WP_Optimize_WebP_Images')) :

class WP_Optimize_WebP_Images {

	private $directory = '';

	private $filename = '';

	private $original_extension = '';

	private $webp_extension = '.webp';

	private $meta = false;

	private $sizes = array();

	private $images = array();

	/**
	 * Constructor
	 */
	private function __construct() {
		add_action('delete_attachment', array($this, 'delete_related_images'), 10, 1);
	}

	/**
	 * Returns singleton instance
	 *
	 * @return WP_Optimize_WebP_Images
	 */
	public static function get_instance() {
		static $instance = null;
		if (null === $instance) {
			$instance = new WP_Optimize_WebP_Images();
		}
		return $instance;
	}

	/**
	 * Deletes related image sizes and alternate webp format images
	 *
	 * @param int $attachment_id
	 * @return void
	 */
	public function delete_related_images($attachment_id) {
		$this->set_meta($attachment_id);
		$this->set_file_info_properties($attachment_id);
		$this->set_sizes();
		$this->set_images();
		$this->delete_images();
		$this->reset();
	}

	/**
	 * Sets meta property with attachment metadata
	 *
	 * @param int $attachment_id
	 * @return void
	 */
	private function set_meta($attachment_id) {
		$this->meta = wp_get_attachment_metadata($attachment_id);
	}

	/**
	 * Sets file information properties
	 *
	 * @param int $attachment_id
	 * @return void
	 */
	private function set_file_info_properties($attachment_id) {
		$file_path = get_attached_file($attachment_id);
		$file_path_info = pathinfo($file_path);
		$this->filename = $file_path_info['filename'];
		$this->original_extension = '.' . $file_path_info['extension'];

		$file = isset($this->meta['file']) ? $this->meta['file'] : '';
		$basename = $file_path_info['basename'];
		$sub_directory = '';
		if (!empty($file)) {
			$sub_directory = str_replace($basename, '', $file);
		}

		$uploads = wp_get_upload_dir();
		$this->directory = $uploads['basedir'] . '/' . $sub_directory;
	}

	/**
	 * Returns all available image sizes for the given attachment id
	 */
	private function set_sizes() {
		if (false !== $this->meta) {
			$this->sizes = isset($this->meta['sizes']) ? $this->meta['sizes'] : array();
		}
	}

	/**
	 * Sets images property
	 *
	 * @return void
	 */
	private function set_images() {
		$webp_format = $this->directory . $this->filename . $this->original_extension . $this->webp_extension;
		$this->images[] = $webp_format;

		foreach ($this->sizes as $size) {
			$original_format = $this->directory . $this->filename . '-' . $size['width'] . 'x' . $size['height'] . $this->original_extension;
			$this->images[] = $original_format;
			$webp_format = $this->directory . preg_replace('/-scaled$/', '', $this->filename) . '-' . $size['width'] . 'x' . $size['height'] . $this->original_extension . $this->webp_extension;
			$this->images[] = $webp_format;
		}

	}

	/**
	 * Delete related images
	 *
	 * @return void
	 */
	private function delete_images() {
		foreach ($this->images as $image) {
			wp_delete_file($image);
		}
	}

	/**
	 * Reset class property values
	 */
	private function reset() {
		$this->directory = '';
		$this->filename = '';
		$this->original_extension = '';
		$this->meta = false;
		$this->sizes = array();
		$this->images = array();
	}
}

endif;

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:24
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:24
giriqfky / giriqfky
0644
class-wp-optimize-webp-images.php
3.242 KB
March 13 2023 19:14:32
giriqfky / giriqfky
0644
class-wp-optimize-webp.php
15.646 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644
class-wpo-htaccess-capabilities.php
1.648 KB
June 21 2022 03:11:04
giriqfky / giriqfky
0644
class-wpo-server-info.php
1.898 KB
June 03 2022 22:20:18
giriqfky / giriqfky
0644
class-wpo-webp-alter-html.php
4.627 KB
September 16 2024 16:17:24
giriqfky / giriqfky
0644
class-wpo-webp-convert.php
1.353 KB
July 06 2023 16:18:20
giriqfky / giriqfky
0644
class-wpo-webp-self-test.php
1.589 KB
October 16 2023 19:36:50
giriqfky / giriqfky
0644
class-wpo-webp-test-run.php
1.316 KB
July 06 2023 16:18:20
giriqfky / giriqfky
0644
class-wpo-webp-utils.php
2.517 KB
May 01 2025 14:24:58
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF