diff options
author | sgiehl <stefan@matomo.org> | 2022-08-17 11:39:27 +0300 |
---|---|---|
committer | sgiehl <stefan@matomo.org> | 2022-08-17 11:39:27 +0300 |
commit | 585da9e91a7528d12b8fac9f3d58911b4eb1a15e (patch) | |
tree | 5f04df990a21d863657d17930890ca783674c1c6 /plugins/SitesManager | |
parent | e3655d38f78b6a2a027c1f35f70ce4cbe29d101b (diff) | |
parent | 3b781619cfab118dab72ff5379768ff00eff0391 (diff) |
Merge branch '4.x-dev' into 5.x-dev
Diffstat (limited to 'plugins/SitesManager')
-rw-r--r-- | plugins/SitesManager/Controller.php | 4 | ||||
-rw-r--r-- | plugins/SitesManager/SitesManager.php | 62 | ||||
-rw-r--r-- | plugins/SitesManager/lang/bg.json | 6 | ||||
-rw-r--r-- | plugins/SitesManager/lang/en.json | 2 | ||||
-rw-r--r-- | plugins/SitesManager/lang/ms.json | 8 | ||||
-rw-r--r-- | plugins/SitesManager/templates/_siteWithoutDataTabs.twig | 4 |
6 files changed, 67 insertions, 19 deletions
diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php index 197dca845e..10a43cd909 100644 --- a/plugins/SitesManager/Controller.php +++ b/plugins/SitesManager/Controller.php @@ -200,8 +200,6 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->cache->save($gtmCacheId, $gtmUsed, 60 * 60 * 24); } - $instructionUrl = SitesManager::getInstructionUrlBySiteType($siteType); - $piwikUrl = Url::getCurrentUrlWithoutFileName(); $jsTag = Request::processRequest('SitesManager.getJavascriptTag', array('idSite' => $this->idSite, 'piwikUrl' => $piwikUrl)); @@ -235,7 +233,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin 'piwikUrl' => $piwikUrl, 'showMatomoLinks' => $showMatomoLinks, 'siteType' => $siteType, - 'instructionUrl' => $instructionUrl, + 'instruction' => SitesManager::getInstructionBySiteType($siteType), 'gtmUsed' => $gtmUsed, 'googleAnalyticsImporterMessage' => $googleAnalyticsImporterMessage, 'tagManagerActive' => $tagManagerActive, diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php index 05cdc7d8ca..09c275a884 100644 --- a/plugins/SitesManager/SitesManager.php +++ b/plugins/SitesManager/SitesManager.php @@ -1,4 +1,5 @@ <?php + /** * Matomo - free/libre analytics platform * @@ -6,6 +7,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * */ + namespace Piwik\Plugins\SitesManager; use Piwik\Access; @@ -18,6 +20,7 @@ use Piwik\Option; use Piwik\Piwik; use Piwik\Plugins\CoreHome\SystemSummary; use Piwik\Settings\Storage\Backend\MeasurableSettingsTable; +use Piwik\SettingsServer; use Piwik\Tracker\Cache; use Piwik\Tracker\FingerprintSalt; use Piwik\Tracker\Model as TrackerModel; @@ -46,15 +49,15 @@ class SitesManager extends \Piwik\Plugin */ public function registerEvents() { - return array( + return [ 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'Tracker.Cache.getSiteAttributes' => array('function' => 'recordWebsiteDataInCache', 'before' => true), + 'Tracker.Cache.getSiteAttributes' => ['function' => 'recordWebsiteDataInCache', 'before' => true], 'Tracker.setTrackerCacheGeneral' => 'setTrackerCacheGeneral', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', 'SitesManager.deleteSite.end' => 'onSiteDeleted', 'System.addSystemSummaryItems' => 'addSystemSummaryItems', 'Request.dispatch' => 'redirectDashboardToWelcomePage', - ); + ]; } public static function isSitesAdminEnabled() @@ -73,9 +76,16 @@ class SitesManager extends \Piwik\Plugin public function addSystemSummaryItems(&$systemSummary) { if (self::isSitesAdminEnabled()) { - $websites = Request::processRequest('SitesManager.getAllSites', array('filter_limit' => '-1')); + $websites = Request::processRequest('SitesManager.getAllSites', ['filter_limit' => '-1']); $numWebsites = count($websites); - $systemSummary[] = new SystemSummary\Item($key = 'websites', Piwik::translate('CoreHome_SystemSummaryNWebsites', $numWebsites), $value = null, $url = array('module' => 'SitesManager', 'action' => 'index'), $icon = '', $order = 10); + $systemSummary[] = new SystemSummary\Item( + 'websites', + Piwik::translate('CoreHome_SystemSummaryNWebsites', $numWebsites), + null, + ['module' => 'SitesManager', 'action' => 'index'], + '', + 10 + ); } } @@ -194,7 +204,7 @@ class SitesManager extends \Piwik\Plugin // we make sure to have the fingerprint salts for the last 3 days incl tmrw in the cache so we don't need to // query the DB directly for these days - $datesToGenerateSalt = array(Date::now()->addDay(1), Date::now(), Date::now()->subDay(1), Date::now()->subDay(2)); + $datesToGenerateSalt = [Date::now()->addDay(1), Date::now(), Date::now()->subDay(1), Date::now()->subDay(2)]; $fingerprintSaltKey = new FingerprintSalt(); foreach ($datesToGenerateSalt as $date) { @@ -235,7 +245,7 @@ class SitesManager extends \Piwik\Plugin { if ($site['keep_url_fragment'] == self::KEEP_URL_FRAGMENT_YES) { return true; - } else if ($site['keep_url_fragment'] == self::KEEP_URL_FRAGMENT_NO) { + } elseif ($site['keep_url_fragment'] == self::KEEP_URL_FRAGMENT_NO) { return false; } @@ -273,7 +283,7 @@ class SitesManager extends \Piwik\Plugin $excludedIps .= ',' . $globalExcludedIps; - $ipRanges = array(); + $ipRanges = []; foreach (explode(',', $excludedIps) as $ip) { $ipRange = API::getInstance()->getIpsForRange($ip); if ($ipRange !== false) { @@ -348,7 +358,7 @@ class SitesManager extends \Piwik\Plugin */ private function getTrackerHosts($urls) { - $hosts = array(); + $hosts = []; foreach ($urls as $url) { $url = parse_url($url); if (isset($url['host'])) { @@ -366,7 +376,7 @@ class SitesManager extends \Piwik\Plugin self::SITE_TYPE_SHOPIFY => 'https://matomo.org/faq/new-to-piwik/how-do-i-install-the-matomo-tracking-code-on-my-shopify-store', self::SITE_TYPE_SQUARESPACE => 'https://matomo.org/faq/new-to-piwik/how-do-i-integrate-matomo-with-squarespace-website', self::SITE_TYPE_WIX => 'https://matomo.org/faq/new-to-piwik/how-do-i-install-the-matomo-analytics-tracking-code-on-wix', - self::SITE_TYPE_WORDPRESS => 'https://matomo.org/faq/new-to-piwik/how-do-i-install-the-matomo-tracking-code-on-wordpress', + self::SITE_TYPE_WORDPRESS => 'https://matomo.org/faq/new-to-piwik/how-do-i-install-the-matomo-tracking-code-on-wordpress/', self::SITE_TYPE_DRUPAL => 'https://matomo.org/faq/new-to-piwik/how-to-integrate-with-drupal/', self::SITE_TYPE_WEBFLOW => 'https://matomo.org/faq/new-to-piwik/how-do-i-install-the-matomo-tracking-code-on-webflow', ]; @@ -374,6 +384,38 @@ class SitesManager extends \Piwik\Plugin return $map[$siteType] ?? false; } + public static function getInstructionBySiteType(string $siteType): string + { + if ($siteType === self::SITE_TYPE_UNKNOWN) { + return ''; + } + + if ($siteType === self::SITE_TYPE_WORDPRESS && !SettingsServer::isMatomoForWordPress()) { + return sprintf( + '%s<br /><br />%s<br /><br />', + Piwik::translate('SitesManager_SiteWithoutDataDetectedSiteWordpress', [ + '<a target="_blank" rel="noreferrer noopener" href="' . self::getInstructionUrlBySiteType($siteType) . '#wpmatomo">', + '</a>', + '<a target="_blank" rel="noreferrer noopener" href="https://wordpress.org/plugins/wp-piwik/">', + '</a>', + ]), + Piwik::translate('SitesManager_SiteWithoutDataDetectedSiteWordpress2', [ + '<a target="_blank" rel="noreferrer noopener" href="https://matomo.org/faq/how-to-install/which-plugin-should-i-use-with-wordpress/">', + '</a>', + ]) + ); + } + + return Piwik::translate( + 'SitesManager_SiteWithoutDataDetectedSite', + [ + ucfirst($siteType), + '<a target="_blank" rel="noreferrer noopener" href="' . self::getInstructionUrlBySiteType($siteType) . '">', + '</a>' + ] + ); + } + public function getClientSideTranslationKeys(&$translationKeys) { $translationKeys[] = "General_Save"; diff --git a/plugins/SitesManager/lang/bg.json b/plugins/SitesManager/lang/bg.json index b853df5ff0..e390274ae9 100644 --- a/plugins/SitesManager/lang/bg.json +++ b/plugins/SitesManager/lang/bg.json @@ -41,7 +41,7 @@ "ExcludedReferrersHelpExamples": "напр. „%1$s“ ще съответства на „%2$s“ и „%3$s“, но не и на „%4$s“", "ExcludedReferrersHelpSubDomains": "За да изключите и всички поддомейни на определено име на хост, добавете точка пред него. напр. „%1$s“ ще изключи „%2$s“, но също и всички негови поддомейни като „%3$s“.", "ExcludedUserAgents": "Изключени потребителски агенти", - "ExtraInformationNeeded": "За да настроите Matomo на Вашата система, може да Ви е необходима следната информация:", + "ExtraInformationNeeded": "За да настройте Matomo на Вашата система, може да Ви е необходима следната информация:", "Format_Utc": "UTC%s", "GlobalExcludedUserAgentHelp1": "Въведете списъка с потребителски агенти, които да изключите от проследяване от Matomo.", "GlobalExcludedUserAgentHelp2": "Можете да използвате това, за да изключите някои ботове от проследяване.", @@ -97,10 +97,10 @@ "SiteSearchUse": "Можете да използвате Matomo да следи и докладва това, което посетителите търсят, посредством търсачката на сайта.", "SiteWithoutDataChoosePreferredWay": "Изберете предпочитания от Вас начин за настройка", "SiteWithoutDataDescription": "Трябва да добавите допълнителен код към Вашия уебсайт или мобилно приложение, ако все още не сте го направили. Проверете опцията си по-долу или %1$sизпратете всички инструкции на съотборник %2$s.", - "SiteWithoutDataDetectedGtm": "Също така установихме, че използвате Мениджър на тагове на Google. Ако предпочитате да настроите Matomo чрез GTM, моля, следвайте това %2$sръководство%3$s.", + "SiteWithoutDataDetectedGtm": "Също така установихме, че използвате Мениджър на тагове на Google. Ако предпочитате да настройте Matomo чрез GTM, моля, следвайте това %2$sръководство%3$s.", "SiteWithoutDataDetectedSite": "Установихме, че използвате сайт %1$s. Просто следвайте инструкциите от това %2$sръководство%3$s.", "SiteWithoutDataGoogleTagManager": "Мениджър на тагове на Google", - "SiteWithoutDataGoogleTagManagerDescription": "Можете да използвате Matomo с Google Tag Manager. За да настроите Matomo Tracking в Google Tag Manager, следвайте инструкциите от това %1$sръководство%2$s.", + "SiteWithoutDataGoogleTagManagerDescription": "Можете да използвате Matomo с Google Tag Manager. За да настройте Matomo Tracking в Google Tag Manager, следвайте инструкциите от това %1$sръководство%2$s.", "SiteWithoutDataIgnoreMessage": "Не показвайте това съобщение през следващия час", "SiteWithoutDataMatomoTagManager": "Мениджър на тагове на Matomo", "SiteWithoutDataMatomoTagManagerNotActive": "Не знаете какво е Мениджър на тагове? Разгледайте нашето %1$sРъководство за мениджър на тагове%2$s. Ако вграждате множество ресурси от уебсайтове на трети страни в уебсайта си, тогава проследяването на уебсайта Ви чрез Мениджъра на тагове може да е по-добър избор за Вас в сравнение с използването на обикновеното проследяване на JavaScript.", diff --git a/plugins/SitesManager/lang/en.json b/plugins/SitesManager/lang/en.json index e3e4166255..5f41ac8a58 100644 --- a/plugins/SitesManager/lang/en.json +++ b/plugins/SitesManager/lang/en.json @@ -97,6 +97,8 @@ "SiteWithoutDataGoogleTagManagerDescription": "You can use Matomo with Google Tag Manager. To setup Matomo Tracking in Google Tag Manager, follow the instructions from this %1$sguide%2$s.", "SiteWithoutDataSinglePageApplicationDescription": "For Single-Page Application or Progressive Web App Tracking. Check out our %1$sguide%2$s.", "SiteWithoutDataDetectedSite": "We've detected you're using a %1$s site. Simply follow the instructions from this %2$sguide%3$s.", + "SiteWithoutDataDetectedSiteWordpress": "We've detected you're using a Wordpress site. Simply %1$sfollow the instructions from this guide%2$s to install the %3$sWP-Matomo plugin%4$s.", + "SiteWithoutDataDetectedSiteWordpress2": "Set up the WordPress plugin already and not seeing any data? Please check %1$sthis FAQ for help%2$s.", "SiteWithoutDataDetectedGtm": "We've also detected you're using a Google Tag Manager. If you prefer to set up Matomo using GTM please follow this %2$sguide%3$s.", "SuperUserAccessCan": "A user with Super User access can also %1$s specify global settings%2$s for new websites.", "Timezone": "Time zone", diff --git a/plugins/SitesManager/lang/ms.json b/plugins/SitesManager/lang/ms.json index 6daf99c8e2..bc67e2c748 100644 --- a/plugins/SitesManager/lang/ms.json +++ b/plugins/SitesManager/lang/ms.json @@ -1,6 +1,12 @@ { "SitesManager": { + "AddMeasurable": "Tambah yang boleh diukur baharu", + "AddSite": "Tambah tapak web baharu", + "AdvancedTimezoneSupportNotFound": "Sokongan zon masa lanjutan tidak ditemui dalam PHP anda (disokong dalam PHP>=5.2). Anda masih boleh memilih offset UTC manual.", + "AliasUrlHelp": "Adalah disyorkan, tetapi tidak diperlukan, untuk menentukan pelbagai URL, satu setiap baris, yang digunakan oleh pelawat anda untuk mengakses tapak web ini. URL alias untuk tapak web tidak akan muncul dalam laporan Perujuk > Laman Web. Ambil perhatian bahawa tidak perlu untuk menentukan URL dengan dan tanpa 'www' kerana Matomo secara automatik menganggap kedua-duanya.", + "ChangingYourTimezoneWillOnlyAffectDataForward": "Menukar zon masa anda hanya akan menjejaskan data pada masa hadapan dan tidak akan digunakan secara retroaktif.", "Currency": "Mata wang", + "CurrencySymbolWillBeUsedForGoals": "Simbol Mata Wang akan dipaparkan di sebelah hasil Matlamat.", "Timezone": "Zon Waktu" } -}
\ No newline at end of file +} diff --git a/plugins/SitesManager/templates/_siteWithoutDataTabs.twig b/plugins/SitesManager/templates/_siteWithoutDataTabs.twig index ff82596f22..85466f9532 100644 --- a/plugins/SitesManager/templates/_siteWithoutDataTabs.twig +++ b/plugins/SitesManager/templates/_siteWithoutDataTabs.twig @@ -16,8 +16,8 @@ <div id="integrations" class="col s12"> <h3>{{ 'SitesManager_Integrations'|translate }}</h3> - {% if siteType != constant('Piwik\\Plugins\\SitesManager\\SitesManager::SITE_TYPE_UNKNOWN') and instructionUrl %} - <p>{{ 'SitesManager_SiteWithoutDataDetectedSite'|translate(siteType|capitalize, '<a target="_blank" rel="noreferrer noopener" href="' ~ instructionUrl ~ '">','</a>')|raw }}</p> + {% if instruction %} + <p>{{ instruction|raw }}</p> {% if gtmUsed %} <p>{{ 'SitesManager_SiteWithoutDataDetectedGtm'|translate(siteType|capitalize, '<a target="_blank" rel="noreferrer noopener" href="https://matomo.org/faq/new-to-piwik/how-do-i-use-matomo-analytics-within-gtm-google-tag-manager">','</a>')|raw }}</p> |