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