|
|
@ -1,5 +1,41 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Start | Работа с проверкой мультисайтовости и стендов */ |
|
|
|
|
|
|
|
class SiteEnvironment |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public string $mode; |
|
|
|
|
|
|
|
public string $region; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(string $host = null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$map = [ |
|
|
|
|
|
|
|
'cosmopet.ru' => ['mode' => 'production', 'region' => 'ru'], |
|
|
|
|
|
|
|
'cosmopet.ae' => ['mode' => 'production', 'region' => 'ae'], |
|
|
|
|
|
|
|
'cosmopet-test-ru.cp.good-production.xyz' => ['mode' => 'develope', 'region' => 'ru'], |
|
|
|
|
|
|
|
'cosmopet-test-ae.cp.good-production.xyz' => ['mode' => 'develope', 'region' => 'ae'], |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$host = strtolower($host ?: $_SERVER['SERVER_NAME']); |
|
|
|
|
|
|
|
$config = $map[$host] ?? ['mode' => 'develope', 'region' => 'unknown']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->site_mode = $config['mode']; |
|
|
|
|
|
|
|
$this->site_region = $config['region']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_filter('timber/twig', function (\Twig\Environment $twig) { |
|
|
|
|
|
|
|
$site_env = new SiteEnvironment(); |
|
|
|
|
|
|
|
$twig->addGlobal('site_region', $site_env->site_region); |
|
|
|
|
|
|
|
$twig->addGlobal('site_mode', $site_env->site_mode); |
|
|
|
|
|
|
|
return $twig; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/* End | Работа с проверкой мультисайтовости и стендов */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_filter('woocommerce_currency_symbol', 'change_aed_currency_symbol', 10, 2); |
|
|
|
add_filter('woocommerce_currency_symbol', 'change_aed_currency_symbol', 10, 2); |
|
|
|
|
|
|
|
|
|
|
|
function change_aed_currency_symbol($currency_symbol, $currency) { |
|
|
|
function change_aed_currency_symbol($currency_symbol, $currency) { |
|
|
|