PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / ProfessionalServices / Advertising.php
matomo / app / core / ProfessionalServices Last commit date
Advertising.php 1 year ago
Advertising.php
104 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\ProfessionalServices;
10
11 use Piwik\Plugin;
12 use Piwik\Config;
13 use Piwik\Url;
14 /**
15 * Advertising for providers of Professional Support for Piwik.
16 *
17 * Lets you for example check whether advertising is enabled, generate links for different landing pages etc.
18 *
19 * @since 2.16.0
20 */
21 class Advertising
22 {
23 public const CAMPAIGN_NAME_PROFESSIONAL_SERVICES = 'App_ProfessionalServices';
24 /**
25 * @var Plugin\Manager
26 */
27 private $pluginManager;
28 /**
29 * @var Config
30 */
31 private $config;
32 public function __construct(Plugin\Manager $pluginManager, Config $config)
33 {
34 $this->pluginManager = $pluginManager;
35 $this->config = $config;
36 }
37 /**
38 * Returns true if it is ok to show some advertising in the Piwik UI.
39 * @return bool
40 */
41 public function areAdsForProfessionalServicesEnabled()
42 {
43 return self::isAdsEnabledInConfig($this->config->General);
44 }
45 /**
46 * Get URL for promoting Professional Services for Piwik
47 *
48 * @param string $campaignMedium
49 * @param string $campaignContent
50 * @return string
51 */
52 public function getPromoUrlForProfessionalServices($campaignMedium, $campaignContent = '')
53 {
54 return Url::addCampaignParametersToMatomoLink('https://matomo.org/support-plans/', self::CAMPAIGN_NAME_PROFESSIONAL_SERVICES, null, $campaignMedium);
55 }
56 /**
57 * Appends campaign parameters to the given URL for promoting any Professional Support for Piwik service.
58 *
59 * @param string $url
60 * @param string $campaignName
61 * @param string $campaignMedium
62 * @param string $campaignContent
63 * @param string $campaignSource
64 * @return string
65 */
66 public function addPromoCampaignParametersToUrl($url, $campaignName, $campaignMedium, $campaignContent = '', $campaignSource = null)
67 {
68 if (empty($url)) {
69 return '';
70 }
71 return Url::addCampaignParametersToMatomoLink($url, $campaignName, $campaignSource, $campaignMedium . ($campaignContent !== '' ? '.' . $campaignContent : ''));
72 }
73 /**
74 * @deprecated
75 * Generates campaign URL parameters that can be used with promoting Professional Support service.
76 *
77 * @param string $campaignName
78 * @param string $campaignMedium
79 * @param string $campaignContent Optional
80 * @return string URL parameters without a leading ? or &
81 */
82 private function getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent = '')
83 {
84 $campaignName = sprintf('pk_campaign=%s&pk_medium=%s&pk_source=Matomo_App', $campaignName, $campaignMedium);
85 if (!empty($campaignContent)) {
86 $campaignName .= '&pk_content=' . $campaignContent;
87 }
88 return $campaignName;
89 }
90 /**
91 * @param $configGeneralSection
92 * @return bool
93 */
94 public static function isAdsEnabledInConfig($configGeneralSection)
95 {
96 $oldSettingValue = \false;
97 if (isset($configGeneralSection['piwik_pro_ads_enabled'])) {
98 $oldSettingValue = @$configGeneralSection['piwik_pro_ads_enabled'];
99 }
100 $newSettingValue = @$configGeneralSection['piwik_professional_support_ads_enabled'];
101 return (bool) ($newSettingValue || $oldSettingValue);
102 }
103 }
104