قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-22 23:17:46 +00:00

* Fix PHPStan issues in plugins/SitesManager/SiteContentDetection * update baseline * remove unneeded access check
92 خطوط
2.9 KiB
PHP
92 خطوط
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
namespace Piwik\Plugins\SitesManager\SiteContentDetection;
|
|
|
|
use Piwik\Piwik;
|
|
use Piwik\Plugin\Manager;
|
|
use Piwik\SettingsPiwik;
|
|
use Piwik\SiteContentDetector;
|
|
use Piwik\Url;
|
|
use Piwik\View;
|
|
|
|
class WordPress extends SiteContentDetectionAbstract
|
|
{
|
|
public static function getName(): string
|
|
{
|
|
return 'WordPress';
|
|
}
|
|
|
|
public static function getIcon(): string
|
|
{
|
|
return './plugins/SitesManager/images/wordpress.svg';
|
|
}
|
|
|
|
public static function getContentType(): int
|
|
{
|
|
return self::TYPE_CMS;
|
|
}
|
|
|
|
public static function getInstructionUrl(): ?string
|
|
{
|
|
return Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/new-to-piwik/how-do-i-install-the-matomo-tracking-code-on-wordpress/');
|
|
}
|
|
|
|
public static function getPriority(): int
|
|
{
|
|
return 30;
|
|
}
|
|
|
|
public function isDetected(?string $data = null, ?array $headers = null): bool
|
|
{
|
|
$needle = '/wp-content';
|
|
return (strpos($data, $needle) !== false);
|
|
}
|
|
|
|
public function renderInstructionsTab(SiteContentDetector $detector): string
|
|
{
|
|
$view = new View("@SitesManager/_wordpressTabInstructions");
|
|
$request = \Piwik\Request::fromRequest();
|
|
$idSite = $request->getIntegerParameter('idSite', 0);
|
|
$period = $request->getStringParameter('period', 'day');
|
|
$date = $request->getStringParameter('date', 'yesterday');
|
|
$view->authLink = SettingsPiwik::getPiwikUrl() . 'index.php?' .
|
|
Url::getQueryStringFromParameters([
|
|
'idSite' => $idSite,
|
|
'date' => urlencode($date),
|
|
'period' => urlencode($period),
|
|
'module' => 'UsersManager',
|
|
'action' => 'addNewToken',
|
|
]);
|
|
$view->faqLink = Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/general/faq_114/');
|
|
$view->sendHeadersWhenRendering = false;
|
|
$view->site = ['id' => $idSite, 'name' => ''];
|
|
$view->isJsTrackerInstallCheckAvailable = Manager::getInstance()->isPluginActivated('JsTrackerInstallCheck');
|
|
return $view->render();
|
|
}
|
|
|
|
public function renderOthersInstruction(SiteContentDetector $detector): string
|
|
{
|
|
if ($detector->wasDetected(self::getId())) {
|
|
return ''; // don't show on others page if tab is being displayed
|
|
}
|
|
|
|
return sprintf(
|
|
'<p>%s</p>',
|
|
Piwik::translate(
|
|
'SitesManager_SiteWithoutDataWordpressDescription',
|
|
[
|
|
'<a target="_blank" rel="noreferrer noopener" href="' . Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/new-to-piwik/how-do-i-install-the-matomo-tracking-code-on-wordpress/') . '">',
|
|
'</a>',
|
|
]
|
|
)
|
|
);
|
|
}
|
|
}
|