PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
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 / classes / WpMatomo / Admin / Marketplace.php
matomo / classes / WpMatomo / Admin Last commit date
PluginSuggestions 2 months ago TrackingSettings 2 months ago views 2 months ago AccessSettings.php 4 years ago AdBlockDetector.php 7 months ago Admin.php 2 months ago AdminSettings.php 2 months ago AdminSettingsInterface.php 6 years ago AdvancedSettings.php 10 months ago Chart.php 2 months ago CookieConsent.php 4 years ago Dashboard.php 2 months ago ExclusionSettings.php 7 months ago GeolocationSettings.php 2 years ago GetStarted.php 2 months ago ImportWpStatistics.php 2 months ago Info.php 2 months ago InvalidIpException.php 4 years ago Marketplace.php 2 months ago MarketplaceSetupWizard.php 2 months ago MarketplaceSetupWizardBody.php 3 months ago MatomoPage.php 2 months ago MatomoPageContent.php 2 months ago Menu.php 2 months ago PluginMeasurableSettings.php 2 years ago PrivacySettings.php 1 year ago SafeModeMenu.php 2 months ago Summary.php 2 months ago SystemReport.php 2 months ago TrackingSettings.php 4 months ago WhatsNewNotifications.php 2 months ago
Marketplace.php
108 lines
1 <?php
2 /**
3 * Matomo - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 * @package matomo
8 */
9
10 namespace WpMatomo\Admin;
11
12 use WpMatomo\Feature;
13 use WpMatomo\Settings;
14 use WpMatomo\Capabilities;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // if accessed directly
18 }
19
20 class Marketplace implements MatomoPageContent {
21
22 /**
23 * @var Settings
24 */
25 private $settings;
26
27 public function __construct( Settings $settings ) {
28 $this->settings = $settings;
29 }
30
31 public function get_active_tab() {
32 $active_tab = 'marketplace';
33
34 $valid_tabs = $this->get_valid_tabs();
35
36 if ( isset( $_REQUEST['tab'] )
37 && in_array( wp_unslash( $_REQUEST['tab'] ), $valid_tabs, true )
38 ) {
39 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
40 $active_tab = wp_unslash( $_REQUEST['tab'] );
41 }
42
43 return $active_tab;
44 }
45
46 public function show() {
47 $settings = $this->settings;
48 $valid_tabs = [];
49 $active_tab = '';
50
51 if ( ! is_plugin_active( MATOMO_MARKETPLACE_PLUGIN_NAME ) ) {
52 $active_tab = $this->get_active_tab();
53 $valid_tabs = $this->get_valid_tabs();
54
55 $marketplace_setup_wizard = \WpMatomo::get_active_feature( MarketplaceSetupWizard::class );
56 }
57
58 $matomo_currency = $this->get_currency_based_on_timezone();
59
60 include dirname( __FILE__ ) . '/views/marketplace.php';
61 }
62
63 private function get_valid_tabs() {
64 $valid_tabs = [ 'marketplace' ];
65 if ( $this->can_user_manage() ) {
66 if ( current_user_can( 'install_plugins' ) ) {
67 $valid_tabs[] = 'install';
68 }
69 $valid_tabs[] = 'subscriptions';
70 }
71 return $valid_tabs;
72 }
73
74 private function can_user_manage() {
75 // only someone who can activate plugins is allowed to manage subscriptions
76 if ( $this->is_multisite() ) {
77 return is_super_admin();
78 }
79
80 return current_user_can( Capabilities::KEY_SUPERUSER );
81 }
82
83 private function is_multisite() {
84 return function_exists( 'is_multisite' ) && is_multisite();
85 }
86
87 private function get_currency_based_on_timezone() {
88 if ( ! function_exists( 'wp_timezone' ) ) {
89 return 'EUR';
90 }
91
92 $timezone = \wp_timezone();
93 $now = new \DateTime( 'now', $timezone );
94 $offset = $now->getOffset() / 3600;
95
96 // if timezone is not european, use USD
97 if ( $offset >= 0 && $offset <= 4 ) {
98 return 'EUR';
99 } else {
100 return 'USD';
101 }
102 }
103
104 public function get_title() {
105 return null;
106 }
107 }
108