| Server IP : 185.252.147.100 / Your IP : 216.73.217.33 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/east-point.site/public/wp-content/plugins/staatic/src/Module/ |
Upload File : |
<?php
declare(strict_types=1);
namespace Staatic\WordPress\Module;
use Staatic\WordPress\Setting\Advanced\HttpToHttpsSetting;
/**
* This module ensures that internal HTTP requests by the background publisher are
* forced to the http scheme when http to https setting is enabled.
*
* It also tricks WordPress into thinking any request is served over HTTPS when
* requested by the crawler.
*/
final class HttpsToHttpDowngrade implements ModuleInterface
{
/**
* @var bool
*/
private $httpToHttps;
public function __construct(HttpToHttpsSetting $httpToHttps)
{
$this->httpToHttps = $httpToHttps->value();
if ($this->shouldEmulateHttps()) {
$_SERVER['HTTPS'] = \true;
}
}
public function hooks(): void
{
add_filter('staatic_background_publisher_query_url', [$this, 'updateQueryUrl'], 10);
}
/**
* @param string $url
*/
public function updateQueryUrl($url): string
{
if ($this->httpToHttps) {
$url = preg_replace('~^https~', 'http', $url);
}
return $url;
}
private function shouldEmulateHttps(): bool
{
return $this->httpToHttps && isset($_SERVER['HTTP_X_STAATIC_REQUEST']);
}
}