Admin
5 years ago
Commands
6 years ago
Db
6 years ago
Ecommerce
6 years ago
Report
6 years ago
Site
5 years ago
TrackingCode
5 years ago
User
5 years ago
views
6 years ago
API.php
5 years ago
Access.php
6 years ago
AjaxTracker.php
5 years ago
Annotations.php
6 years ago
Bootstrap.php
6 years ago
Capabilities.php
6 years ago
Compatibility.php
6 years ago
Email.php
5 years ago
Installer.php
6 years ago
Logger.php
5 years ago
OptOut.php
5 years ago
Paths.php
6 years ago
PrivacyBadge.php
6 years ago
Referral.php
6 years ago
Roles.php
6 years ago
ScheduledTasks.php
6 years ago
Settings.php
5 years ago
Site.php
6 years ago
TrackingCode.php
5 years ago
Uninstaller.php
6 years ago
Updater.php
6 years ago
User.php
6 years ago
Site.php
45 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; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // if accessed directly |
| 14 | } |
| 15 | |
| 16 | class Site { |
| 17 | |
| 18 | const SITE_MAPPING_PREFIX = 'matomo-site-id-'; |
| 19 | |
| 20 | /** |
| 21 | * @api |
| 22 | */ |
| 23 | public function get_current_matomo_site_id() { |
| 24 | return self::get_matomo_site_id( get_current_blog_id() ); |
| 25 | } |
| 26 | |
| 27 | public static function get_matomo_site_id( $blog_id ) { |
| 28 | return get_site_option( self::SITE_MAPPING_PREFIX . $blog_id ); |
| 29 | } |
| 30 | |
| 31 | public static function map_matomo_site_id( $blog_id, $matomo_id_site ) { |
| 32 | $key = self::SITE_MAPPING_PREFIX . $blog_id; |
| 33 | |
| 34 | if ( null === $matomo_id_site || false === $matomo_id_site ) { |
| 35 | delete_site_option( $key ); |
| 36 | } else { |
| 37 | update_site_option( $key, $matomo_id_site ); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | public function uninstall() { |
| 42 | Uninstaller::uninstall_site_meta( self::SITE_MAPPING_PREFIX ); |
| 43 | } |
| 44 | } |
| 45 |