![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/CoreBundle/Twig/Helper/ |
<?php namespace Mautic\CoreBundle\Twig\Helper; use Mautic\CoreBundle\Helper\CoreParametersHelper; final class AnalyticsHelper { private string $code; public function __construct(CoreParametersHelper $parametersHelper) { $this->code = htmlspecialchars_decode((string) $parametersHelper->get('google_analytics')); } public function getCode(): string { return $this->code; } /** * @param string $content */ public function addCode($content): string { // Add analytics $analytics = $this->getCode(); // Check for html doc if (!str_contains($content, '<html')) { $content = "<html>\n<head>{$analytics}</head>\n<body>{$content}</body>\n</html>"; } elseif (!str_contains($content, '<head>')) { $content = str_replace('<html>', "<html>\n<head>\n{$analytics}\n</head>", $content); } elseif (!empty($analytics)) { $content = str_replace('</head>', $analytics."\n</head>", $content); } return $content; } public function getName(): string { return 'analytics'; } }