TrackingSettings
4 years ago
views
3 years ago
AccessSettings.php
4 years ago
Admin.php
4 years ago
AdminSettings.php
4 years ago
AdminSettingsInterface.php
6 years ago
AdvancedSettings.php
4 years ago
Chart.php
4 years ago
CookieConsent.php
4 years ago
Dashboard.php
4 years ago
ExclusionSettings.php
4 years ago
GeolocationSettings.php
4 years ago
GetStarted.php
4 years ago
ImportWpStatistics.php
4 years ago
Info.php
4 years ago
InvalidIpException.php
4 years ago
Marketplace.php
4 years ago
Menu.php
3 years ago
PrivacySettings.php
4 years ago
SafeModeMenu.php
4 years ago
Summary.php
4 years ago
SystemReport.php
3 years ago
TrackingSettings.php
4 years ago
AdminSettings.php
100 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\Access; |
| 13 | use WpMatomo\Settings; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; // if accessed directly |
| 17 | } |
| 18 | |
| 19 | class AdminSettings { |
| 20 | const TAB_TRACKING = 'tracking'; |
| 21 | const TAB_ACCESS = 'access'; |
| 22 | const TAB_EXCLUSIONS = 'exlusions'; |
| 23 | const TAB_PRIVACY = 'privacy'; |
| 24 | const TAB_GEOLOCATION = 'geolocation'; |
| 25 | const TAB_ADVANCED = 'advanced'; |
| 26 | |
| 27 | /** |
| 28 | * @var Settings |
| 29 | */ |
| 30 | private $settings; |
| 31 | |
| 32 | public function __construct( Settings $settings ) { |
| 33 | $this->settings = $settings; |
| 34 | } |
| 35 | |
| 36 | public static function make_url( $tab ) { |
| 37 | global $_parent_pages; |
| 38 | $menu_slug = Menu::SLUG_SETTINGS; |
| 39 | |
| 40 | if ( is_multisite() && is_network_admin() ) { |
| 41 | if ( isset( $_parent_pages[ $menu_slug ] ) ) { |
| 42 | $parent_slug = $_parent_pages[ $menu_slug ]; |
| 43 | if ( $parent_slug && ! isset( $_parent_pages[ $parent_slug ] ) ) { |
| 44 | $url = network_admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); |
| 45 | } else { |
| 46 | $url = network_admin_url( 'admin.php?page=' . $menu_slug ); |
| 47 | } |
| 48 | } else { |
| 49 | $url = ''; |
| 50 | } |
| 51 | } else { |
| 52 | $url = menu_page_url( $menu_slug, false ); |
| 53 | } |
| 54 | |
| 55 | return add_query_arg( [ 'tab' => $tab ], $url ); |
| 56 | } |
| 57 | |
| 58 | public function show() { |
| 59 | $access = new Access( $this->settings ); |
| 60 | $access_settings = new AccessSettings( $access, $this->settings ); |
| 61 | $tracking = new TrackingSettings( $this->settings ); |
| 62 | $exclusions = new ExclusionSettings( $this->settings ); |
| 63 | $geolocation = new GeolocationSettings( $this->settings ); |
| 64 | $privacy = new PrivacySettings( $this->settings ); |
| 65 | $advanced = new AdvancedSettings( $this->settings ); |
| 66 | $setting_tabs = [ |
| 67 | self::TAB_TRACKING => $tracking, |
| 68 | self::TAB_ACCESS => $access_settings, |
| 69 | self::TAB_PRIVACY => $privacy, |
| 70 | self::TAB_EXCLUSIONS => $exclusions, |
| 71 | self::TAB_GEOLOCATION => $geolocation, |
| 72 | self::TAB_ADVANCED => $advanced, |
| 73 | ]; |
| 74 | |
| 75 | $active_tab = self::TAB_TRACKING; |
| 76 | |
| 77 | if ( $this->settings->is_network_enabled() && ! is_network_admin() ) { |
| 78 | $active_tab = self::TAB_EXCLUSIONS; |
| 79 | $setting_tabs = [ |
| 80 | self::TAB_EXCLUSIONS => $exclusions, |
| 81 | self::TAB_PRIVACY => $privacy, |
| 82 | ]; |
| 83 | } |
| 84 | |
| 85 | $setting_tabs = apply_filters( 'matomo_setting_tabs', $setting_tabs, $this->settings ); |
| 86 | |
| 87 | if ( ! empty( $_GET['tab'] ) ) { |
| 88 | $tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) ); |
| 89 | if ( isset( $setting_tabs[ $tab ] ) ) { |
| 90 | $active_tab = $tab; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | $content_tab = $setting_tabs[ $active_tab ]; |
| 95 | $matomo_settings = $this->settings; |
| 96 | |
| 97 | include dirname( __FILE__ ) . '/views/settings.php'; |
| 98 | } |
| 99 | } |
| 100 |