GRAYBYTE WORDPRESS FILE MANAGER1550

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/swamivivekananda.co.in/wp-content/plugins/wp-optimize/webp/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/swamivivekananda.co.in/wp-content/plugins/wp-optimize/webp//class-wpo-webp-utils.php
<?php

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

use \WebPConvert\Convert\ConverterFactory;

require_once WPO_PLUGIN_MAIN_PATH . 'vendor/autoload.php';

if (!class_exists('WPO_WebP_Utils')) :

class WPO_WebP_Utils {

	/**
	 * Determines whether we can do webp conversion or not
	 *
	 * @return bool
	 */
	public static function can_do_webp_conversion() {
		$webp_conversion = WP_Optimize()->get_options()->get_option('webp_conversion', false);
		$webp_converters = WP_Optimize()->get_options()->get_option('webp_converters', false);
		return $webp_conversion && !empty($webp_converters);
	}

	/**
	 * Convert given image file to webp format
	 *
	 * @param string $source Path of image file
	 *
	 * @return void
	 */
	public static function do_webp_conversion($source) {
		$webp_converter = new WPO_WebP_Convert();
		$webp_converter->convert($source);
	}

	/**
	 * Converts an image to WebP format using a specified converter.
	 *
	 * This method acts as a wrapper for the `WebPConvert\Convert\Converters\AbstractConverter::doConvert()` method
	 * from the `webp-convert` library.
	 *
	 * @param string $converter   The converter to be used for the conversion process.
	 * @param string $source      The path to the source image file.
	 * @param string $destination The path to the destination WebP image file.
	 */
	public static function perform_webp_conversion($converter, $source, $destination) {
		$converter_instance = ConverterFactory::makeConverter(
			$converter,
			$source,
			$destination
		);

		set_error_handler(array(__CLASS__, 'handle_webp_conversion_warnings'), E_WARNING); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler -- This is needed in order to suppress PHP warnings thrown by third party library

		$converter_instance->doConvert();

		restore_error_handler();
	}

	/**
	 * Custom error handler for handling PHP warnings during the WebP conversion process.
	 *
	 * @param int    $errno  The level of the error raised, as an integer.
	 * @param string $errstr The error message.
	 *
	 * @return bool
	 */
	public static function handle_webp_conversion_warnings($errno, $errstr) {
		$patterns = array(
			'/unlink\(.+\): No such file or directory/',
			'/rename\(.+\): No such file or directory/',
			'/filesize\(\): stat failed for/',
		);

		foreach ($patterns as $pattern) {
			if (preg_match($pattern, $errstr)) {
				// Suppress the warning by returning true
				return true;
			}
		}

		// For other PHP warnings, use the default PHP error handler by returning false
		return false;
	}
}

endif;

[ 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
class-wp-optimize-webp-images.php
3.242 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wp-optimize-webp.php
15.646 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wpo-htaccess-capabilities.php
1.648 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wpo-server-info.php
1.898 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wpo-webp-alter-html.php
4.627 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wpo-webp-convert.php
1.353 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wpo-webp-self-test.php
1.589 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wpo-webp-test-run.php
1.316 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644
class-wpo-webp-utils.php
2.517 KB
June 23 2025 07:12:38
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF