ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_CookieConsent
|
||||
* @copyright Copyright (c) 2025 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\CookieConsent\Plugin\Html;
|
||||
|
||||
use Magento\Framework\App\Response\Http;
|
||||
use Plumrocket\CookieConsent\Block\Html\HeadScripts as HeadScriptsBlock;
|
||||
use Plumrocket\CookieConsent\Helper\Config;
|
||||
|
||||
/**
|
||||
* @since 2.0.4
|
||||
*/
|
||||
class HeadScripts
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\CookieConsent\Helper\Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\CookieConsent\Helper\Config $config
|
||||
*/
|
||||
public function __construct(
|
||||
Config $config
|
||||
) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\App\Response\Http $subject
|
||||
* @return void
|
||||
*/
|
||||
public function beforeSendResponse(Http $subject): void
|
||||
{
|
||||
if (! $this->config->isModuleEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = $subject->getContent();
|
||||
if(! is_string($content) || strpos($content, HeadScriptsBlock::SCRIPT_TAG_REPLACEMENT) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$subject->setContent(
|
||||
str_replace(HeadScriptsBlock::SCRIPT_TAG_REPLACEMENT, 'script', $content)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user