diff options
author | Zoltan Flamis <flamisz@gmail.com> | 2021-03-29 06:42:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 06:42:17 +0300 |
commit | d26f304da8d0a0f995abafc11501676dad6be846 (patch) | |
tree | 64e477e592c947fbcf54dcfcd120b6461381ca4e /plugins/SitesManager/GtmSiteTypeGuesser.php | |
parent | 8402837f40dbc1e35ab3012dc28a37bbf3e66828 (diff) |
Improve no data tracked yet screen (#17367)4.3.0-b2
* wip
* wip
* wip
* wip
* wip
* tabs and basic structure
* wip
* wip
* tagmanager tab
* fix send email link
* use element, add comment
* use widget loader
* test wip
* site type guesser class
* add sharepoint guess
* catch http request exception
* update ui test images
* cache site types and gtm
* cache DI
* fill untranslated text
Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'plugins/SitesManager/GtmSiteTypeGuesser.php')
-rw-r--r-- | plugins/SitesManager/GtmSiteTypeGuesser.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/SitesManager/GtmSiteTypeGuesser.php b/plugins/SitesManager/GtmSiteTypeGuesser.php new file mode 100644 index 0000000000..d79313c275 --- /dev/null +++ b/plugins/SitesManager/GtmSiteTypeGuesser.php @@ -0,0 +1,68 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\SitesManager; + +use Piwik\Plugins\SitesManager\SitesManager; + +class GtmSiteTypeGuesser +{ + public function guessSiteTypeFromResponse($response) + { + if ($response === false) { + return SitesManager::SITE_TYPE_UNKNOWN; + } + + $needle = '/wp-content'; + if (strpos($response['data'], $needle) !== false) { + return SitesManager::SITE_TYPE_WORDPRESS; + } + + $needle = '<!-- This is Squarespace. -->'; + if (strpos($response['data'], $needle) !== false) { + return SitesManager::SITE_TYPE_SQUARESPACE; + } + + $needle = 'X-Wix-Published-Version'; + if (strpos($response['data'], $needle) !== false) { + return SitesManager::SITE_TYPE_WIX; + } + + // https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Application/WebApplication.php#L516 + // Joomla was the outcome of a fork of Mambo on 17 August 2005 - https://en.wikipedia.org/wiki/Joomla + if (isset($response['headers']['expires']) && $response['headers']['expires'] === 'Wed, 17 Aug 2005 00:00:00 GMT') { + return SitesManager::SITE_TYPE_JOOMLA; + } + + $needle = 'Shopify.theme'; + if (strpos($response['data'], $needle) !== false) { + return SitesManager::SITE_TYPE_SHOPIFY; + } + + $needle = 'content="Microsoft SharePoint'; + if (strpos($response['data'], $needle) !== false) { + return SitesManager::SITE_TYPE_SHAREPOINT; + } + + return SitesManager::SITE_TYPE_UNKNOWN; + } + + public function guessGtmFromResponse($response) + { + if ($response === false) { + return false; + } + + $needle = 'gtm.start'; + if (strpos($response['data'], $needle) !== false) { + return true; + } + + return false; + } +} |