PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.12.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.12.1
5.12.1 5.12.0 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 / GeolocationSettings.php
matomo / classes / WpMatomo / Admin Last commit date
Marketplace 1 month ago PluginSuggestions 1 week ago TrackingSettings 1 week ago views 1 week ago AccessSettings.php 1 week ago AdBlockDetector.php 8 months ago Admin.php 1 month ago AdminSettings.php 1 week ago AdminSettingsInterface.php 6 years ago AdvancedSettings.php 1 week ago Chart.php 2 months ago CookieConsent.php 4 years ago Dashboard.php 1 week ago ExclusionSettings.php 1 week ago GeolocationSettings.php 1 week ago GetStarted.php 1 week ago ImportWpStatistics.php 1 week ago Info.php 1 week ago InvalidIpException.php 4 years ago Marketplace.php 1 week ago MarketplaceSetupWizard.php 1 week ago MarketplaceSetupWizardBody.php 1 week ago MatomoPage.php 3 months ago MatomoPageContent.php 3 months ago Menu.php 1 week ago PluginMeasurableSettings.php 1 week ago PrivacySettings.php 1 week ago SafeModeMenu.php 1 week ago Summary.php 1 week ago SystemReport.php 1 week ago TrackingSettings.php 1 week ago WhatsNewNotifications.php 3 months ago
GeolocationSettings.php
72 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\Capabilities;
13 use WpMatomo\ScheduledTasks;
14 use WpMatomo\Settings;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // if accessed directly
18 }
19
20 class GeolocationSettings implements AdminSettingsInterface {
21 const NONCE_NAME = 'matomo_geolocation';
22 const FORM_NAME = 'matomo_maxmind_license';
23
24 /**
25 * @var Settings
26 */
27 private $settings;
28
29 public function __construct( Settings $settings ) {
30 $this->settings = $settings;
31 }
32
33 public function get_title() {
34 return esc_html__( 'Geolocation', 'matomo' );
35 }
36
37 public function show_settings() {
38 $invalid_format = $this->update_if_submitted() === false;
39
40 $current_maxmind_license = $this->settings->get_global_option( 'maxmind_license_key' );
41
42 include __DIR__ . '/views/geolocation_settings.php';
43 }
44
45 private function update_if_submitted() {
46 if ( isset( $_POST )
47 && isset( $_POST[ self::FORM_NAME ] )
48 && is_admin()
49 && check_admin_referer( self::NONCE_NAME )
50 && current_user_can( Capabilities::KEY_SUPERUSER ) ) {
51 $maxmind_license = trim( stripslashes( sanitize_text_field( wp_unslash( $_POST[ self::FORM_NAME ] ) ) ) );
52
53 if ( empty( $maxmind_license ) ) {
54 $maxmind_license = '';
55 } elseif ( strlen( $maxmind_license ) > 50 || strlen( $maxmind_license ) < 7 || ! ctype_graph( $maxmind_license ) ) {
56 return false;
57 }
58
59 $this->settings->apply_changes(
60 [
61 'maxmind_license_key' => $maxmind_license,
62 ]
63 );
64
65 // update geoip in the backgronud
66 wp_schedule_single_event( time() + 10, ScheduledTasks::EVENT_GEOIP );
67
68 return true;
69 }
70 }
71 }
72