PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.10.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.10.1
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
Marketplace 1 month ago PluginSuggestions 3 months ago TrackingSettings 2 months ago views 1 month ago AccessSettings.php 4 years ago AdBlockDetector.php 7 months ago Admin.php 1 month ago AdminSettings.php 3 months ago AdminSettingsInterface.php 6 years ago AdvancedSettings.php 10 months ago Chart.php 2 months ago CookieConsent.php 4 years ago Dashboard.php 3 months ago ExclusionSettings.php 7 months ago GeolocationSettings.php 2 years ago GetStarted.php 3 months ago ImportWpStatistics.php 3 months ago Info.php 3 months ago InvalidIpException.php 4 years ago Marketplace.php 1 month ago MarketplaceSetupWizard.php 1 month ago MarketplaceSetupWizardBody.php 1 month ago MatomoPage.php 3 months ago MatomoPageContent.php 3 months ago Menu.php 1 month ago PluginMeasurableSettings.php 2 years ago PrivacySettings.php 1 year ago SafeModeMenu.php 3 months ago Summary.php 3 months ago SystemReport.php 2 months ago TrackingSettings.php 2 months ago WhatsNewNotifications.php 3 months ago
Marketplace.php
118 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 $matomo_marketplace_url = MarketplaceSetupWizardBody::get_marketplace_zip_url();
57 } else {
58 wp_safe_redirect( admin_url( 'admin.php?page=matomo-marketplace&tab=install' ) );
59 }
60
61 $matomo_currency = $this->get_currency_based_on_timezone();
62
63 include dirname( __FILE__ ) . '/views/marketplace.php';
64 }
65
66 private function get_valid_tabs() {
67 $valid_tabs = [];
68 if (
69 ! MarketplaceSetupWizard::is_marketplace_installed()
70 || ! is_plugin_active( MarketplaceSetupWizard::MARKETPLACE_PLUGIN_FILE )
71 ) {
72 $valid_tabs[] = 'marketplace';
73 }
74
75 if ( $this->can_user_manage() ) {
76 if ( current_user_can( 'install_plugins' ) ) {
77 $valid_tabs[] = 'install';
78 }
79 $valid_tabs[] = 'subscriptions';
80 }
81 return $valid_tabs;
82 }
83
84 private function can_user_manage() {
85 // only someone who can activate plugins is allowed to manage subscriptions
86 if ( $this->is_multisite() ) {
87 return is_super_admin();
88 }
89
90 return current_user_can( Capabilities::KEY_SUPERUSER );
91 }
92
93 private function is_multisite() {
94 return function_exists( 'is_multisite' ) && is_multisite();
95 }
96
97 private function get_currency_based_on_timezone() {
98 if ( ! function_exists( 'wp_timezone' ) ) {
99 return 'EUR';
100 }
101
102 $timezone = \wp_timezone();
103 $now = new \DateTime( 'now', $timezone );
104 $offset = $now->getOffset() / 3600;
105
106 // if timezone is not european, use USD
107 if ( $offset >= 0 && $offset <= 4 ) {
108 return 'EUR';
109 } else {
110 return 'USD';
111 }
112 }
113
114 public function get_title() {
115 return null;
116 }
117 }
118