PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.1.6
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.1.6
5.13.0 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 / Bootstrap.php
matomo / classes / WpMatomo Last commit date
Admin 1 year ago Commands 2 years ago Db 2 years ago Ecommerce 2 years ago Report 2 years ago Site 2 years ago TrackingCode 1 year ago Updater 4 years ago User 2 years ago Workarounds 2 years ago WpStatistics 1 year ago views 4 years ago API.php 2 years ago Access.php 4 years ago AjaxTracker.php 1 year ago Annotations.php 4 years ago Bootstrap.php 1 year ago Capabilities.php 4 years ago Compatibility.php 2 years ago Email.php 2 years ago ErrorNotice.php 2 years ago Installer.php 1 year ago Logger.php 2 years ago OptOut.php 4 years ago Paths.php 2 years ago PluginAdminOverrides.php 2 years ago PrivacyBadge.php 4 years ago RedirectOnActivation.php 4 years ago Referral.php 2 years ago Roles.php 1 year ago ScheduledTasks.php 1 year ago Settings.php 1 year ago Site.php 3 years ago TrackingCode.php 1 year ago Uninstaller.php 1 year ago Updater.php 2 years ago User.php 4 years ago
Bootstrap.php
151 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 use Piwik\Application\Environment;
13 use Piwik\FrontController;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // if accessed directly
17 }
18 /**
19 * piwik constants
20 * phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
21 */
22 class Bootstrap {
23 /**
24 * Tests only
25 *
26 * @var bool|null
27 */
28 private static $assume_not_bootstrapped;
29
30 private static $bootstrapped_by_wordpress = false;
31
32 private static $are_incompatible_plugins_filtered = false;
33
34 private static $extra_di_definitions = [];
35
36 private static $environment_bootstrapped = false;
37
38 public static function set_extra_di_definitions( array $definitions ) {
39 if ( ! defined( 'PIWIK_TEST_MODE' ) ) {
40 throw new \Exception( 'set_extra_di_definitions is only for tests' );
41 }
42
43 self::$extra_di_definitions = $definitions;
44 }
45
46 public static function get_extra_di_definitions() {
47 return self::$extra_di_definitions;
48 }
49
50 /**
51 * Tests only
52 *
53 * @internal
54 * @ignore
55 */
56 public static function set_not_bootstrapped() {
57 self::$assume_not_bootstrapped = true;
58 self::$bootstrapped_by_wordpress = false;
59 }
60
61 public static function was_bootstrapped_by_wordpress() {
62 return self::$bootstrapped_by_wordpress;
63 }
64
65 public static function is_environment_bootstrapped() {
66 return self::$environment_bootstrapped;
67 }
68
69 public static function bootstrap_environment() {
70 if ( self::is_environment_bootstrapped() ) {
71 return;
72 }
73
74 if ( ! self::$are_incompatible_plugins_filtered ) {
75 matomo_filter_incompatible_plugins( $GLOBALS['MATOMO_PLUGINS_ENABLED'] );
76
77 self::$are_incompatible_plugins_filtered = true;
78 }
79
80 if ( ! defined( 'PIWIK_ENABLE_DISPATCH' ) ) {
81 define( 'PIWIK_ENABLE_DISPATCH', false );
82 }
83
84 // prevent session related errors during install making it more stable
85 if ( ! defined( 'PIWIK_ENABLE_SESSION_START' ) ) {
86 define( 'PIWIK_ENABLE_SESSION_START', false );
87 }
88
89 if ( ! defined( 'PIWIK_DOCUMENT_ROOT' ) ) {
90 define( 'PIWIK_DOCUMENT_ROOT', plugin_dir_path( MATOMO_ANALYTICS_FILE ) . 'app' );
91 }
92
93 require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php';
94
95 if ( ! defined( 'PIWIK_INCLUDE_PATH' ) ) {
96 define( 'PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT );
97 }
98
99 require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php';
100 // we need to install now
101
102 include_once 'Db/WordPress.php';
103
104 $environment = new Environment( null, self::$extra_di_definitions );
105 $environment->init();
106
107 self::$environment_bootstrapped = true;
108 }
109
110 public function bootstrap() {
111 if ( self::is_bootstrapped() ) {
112 return;
113 }
114
115 self::$bootstrapped_by_wordpress = true;
116 self::$assume_not_bootstrapped = false; // we need to unset it again to prevent recursion
117
118 self::bootstrap_environment();
119
120 FrontController::unsetInstance();
121 $controller = FrontController::getInstance();
122 $controller->init();
123
124 add_action(
125 'set_current_user',
126 function () {
127 $access = \Piwik\Access::getInstance();
128 if ( $access ) {
129 $access->reloadAccess();
130 }
131 }
132 );
133 }
134
135 public static function is_bootstrapped() {
136 if ( true === self::$assume_not_bootstrapped ) {
137 return false;
138 }
139
140 return defined( 'PIWIK_DOCUMENT_ROOT' );
141 }
142
143 /**
144 * @api
145 */
146 public static function do_bootstrap() {
147 $bootstrap = new Bootstrap();
148 $bootstrap->bootstrap();
149 }
150 }
151