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