https://t.me/AnonymousX5
Server : Apache
System : Linux ls31.server.ly 3.10.0-962.3.2.lve1.5.68.el7.x86_64 #1 SMP Wed Apr 6 11:12:23 UTC 2022 x86_64
User : medchoco ( 2906)
PHP Version : 8.3.16
Disable Function : mail
Directory :  /home/medchoco/www/wp-content/plugins/wp-optimize/webp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/medchoco/www/wp-content/plugins/wp-optimize/webp/class-wpo-webp-self-test.php
<?php

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

if (!class_exists('WPO_WebP_Self_Test')) :

class WPO_WebP_Self_Test {

	/**
	 * Decided whether we can get a webp image or not
	 *
	 * @return bool
	 */
	public function get_webp_image() {
		$args = array(
			'headers' => array(
				'accept' => 'image/webp'
			)
		);

		$upload_dir = wp_upload_dir();
		$url =  $upload_dir['baseurl']. '/wpo/images/wpo_logo_small.png.webp';

		$response = wp_remote_get($url, $args);

		if (is_wp_error($response)) return false;
		if (200 != $response['response']['code']) return false;

		$headers = wp_remote_retrieve_headers($response);
		if (method_exists($headers, 'getAll')) {
			$headers = $headers->getAll();
			if ($this->has_webp_mime($headers) && $this->has_vary($headers)) {
				return true;
			}
		}

		return false;
	}

	/**
	 * Determines whether content type header has webp mime or not
	 *
	 * @param array $headers An array of headers
	 *
	 * @return bool
	 */
	private function has_webp_mime($headers) {
		return isset($headers['content-type']) && 0 === strcasecmp('image/webp', $headers['content-type']);
	}

	/**
	 * Determines whether headers has `vary` header or not
	 *
	 * @param array $headers An array of headers
	 *
	 * @return bool
	 */
	private function has_vary($headers) {
		return isset($headers['vary']) && preg_match('/accept/i', $headers['vary']);
	}

	/**
	 * Decided whether webp version is served or not
	 *
	 * @return bool
	 */
	public function is_webp_served() {
		$args = array(
			'headers' => array(
				'accept' => 'image/webp'
			)
		);

		$upload_dir = wp_upload_dir();
		$url =  $upload_dir['baseurl']. '/wpo/images/wpo_logo_small.png';

		$response = wp_remote_get($url, $args);

		if (is_wp_error($response)) return false;
		if (200 != $response['response']['code']) return false;

		$headers = wp_remote_retrieve_headers($response);
		if (method_exists($headers, 'getAll')) {
			$headers = $headers->getAll();
			if ($this->has_webp_mime($headers) && $this->has_vary($headers)) {
				return true;
			}
		}
		return false;
	}

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

endif;

https://t.me/AnonymousX5 - 2025